Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix automatic permissions request #1145

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
20 changes: 1 addition & 19 deletions src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ function preflight(details) {
url.pathname = '/html' + url.pathname;
if (url.searchParams.get('crowd') === 'true') {
url.pathname =
url.pathname.split('/').slice(0, -1).join('/') +
'/crowd-bypassed.html';
url.pathname.split('/').slice(0, -1).join('/') + '/crowd-bypassed.html';
} else {
url.pathname =
url.pathname.split('/').slice(0, -1).join('/') +
Expand Down Expand Up @@ -117,22 +116,6 @@ brws.runtime.onStartup.addListener(() => {
brws.storage.local.set({ version: brws.runtime.getManifest().version });
});

brws.webRequest.onBeforeSendHeaders.addListener(
function (details) {
var headers = details.requestHeaders;
headers = headers.map(function (x) {
if (x.name === "User-Agent") {
x.value = "";
return x;
} else {
return x;
}
});
return { requestHeaders: headers };
},
requestFilter,
["requestHeaders", "blocking"]
);
brws.runtime.onMessage.addListener((request, _, sendResponse) => {
(async () => {
let options = await getOptions();
Expand Down Expand Up @@ -208,4 +191,3 @@ brws.storage.onChanged.addListener(() => {
}
});
});