Skip to content

Commit

Permalink
fix automatic permission request
Browse files Browse the repository at this point in the history
  • Loading branch information
driedpampas committed Oct 2, 2023
1 parent 8f8365c commit 6b9155b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/html/consent.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
border-radius: 8px; /* Increase border radius for a softer look */
transition: background-color 0.3s ease;
}

</style>
</head>
<body>
Expand All @@ -53,10 +52,10 @@ <h2>Thank you for installing FastForward</h2>
This extension collects the tab url when you choose to add a website to the whitelist, and temporarily processes the url of bypassed sites while navigating them. This data never leaves your device.
</p>
<P>
Additionally, if the "Crowd Bypass" option is enabled, the extension may send some bypassed urls to our server to be processed and added to our database in accordance with our <a href="https://FastForward.team/privacy" target="_blank">privacy policy</a>. They are never shared.
Additionally, if the "Crowd Bypass" option is enabled, the extension may send some bypassed urls to our server to be processed and added to our database in accordance with our <a href="https://FastForward.team/privacy" class="link" target="_blank">privacy policy</a>. They are never shared.
</P>
<p>
If you consent to this data collection hit "Agree" to continue. Otherwise hit "Refuse" and the extension will be uninstalled.
If you consent to this data collection hit "Agree" to continue and then allow the permission request. Otherwise hit "Refuse" and the extension will be uninstalled.
</p>
<button id="agree" class="buttons">Agree</button>
<button id="refuse" class="buttons">Refuse</button>
Expand Down
17 changes: 16 additions & 1 deletion src/html/consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,23 @@ async function getConsentStatus() {
// Event listener for "Agree" button
document.querySelector('#agree').addEventListener('click', async function () {
console.log("Agree button clicked.");
const permissionsToRequest = {
origins: ["<all_urls>"],
};
function onResponse(response) {
if (response) {
console.log("Permission was granted");
window.close(); // Close the window after permission is granted
} else {
console.log("Permission was refused");
browser.management.uninstallSelf();
}
return browser.permissions.getAll();
}
const response = await browser.permissions.request(permissionsToRequest);
const currentPermissions = await onResponse(response);
console.log(`Current permissions:`, currentPermissions);
await saveConsentStatus('consent-granted');
window.close();
});

// Event listener for "Refuse" button
Expand Down

0 comments on commit 6b9155b

Please sign in to comment.