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

Firefox MV3 Migration #462

Merged
merged 17 commits into from
May 22, 2024
Prev Previous commit
Next Next commit
changed active tab handler
  • Loading branch information
OliverWang13 committed May 5, 2024
commit 015d9054364e91d1c5724345601b581787b65082
20 changes: 17 additions & 3 deletions src/background/protection/protection.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ const listenerCallbacks = {
* @returns {array}
*/
onBeforeSendHeaders: async (details) => {
// if (!setup){
// initSetup();
// }
await updateDomainlist(details);
},

/**
* @param {object} details - retrieved info passed into callback
*/
onHeadersReceived: async (details) => {
//if (!setup){
//initSetup();
//}
await logData(details);
await sendData();

Expand Down Expand Up @@ -123,6 +123,10 @@ async function sendData(){
// activeTabID = tabs.id;
// }
// });

let activeTab = await chrome.tabs.query({ active: true, currentWindow: true });
let activeTabID = activeTab.length > 0 ? activeTab[0].id : null;

let currentDomain = await getCurrentParsedDomain();
// console.log("activeTabID: ",activeTabID);
// console.log("DP3P: ", domPrev3rdParties);
Expand All @@ -133,6 +137,16 @@ async function sendData(){
// console.log("test test3: ", tabs[activeTabID]["REQUEST_DOMAINS"][currentDomain]);
let data = ["Please reload the site"];

// if (activeTabID == 0){
// console.log("activeTabID is zero!!!");
// await chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
// console.log("tabs.id: ",tabs.id);
// if (tabs.id) {
// activeTabID = tabs.id;
// }
// });
// }

if (tabs[activeTabID] !== undefined) {
let info = await tabs[activeTabID]["REQUEST_DOMAINS"];
data = Object.keys(info);
Expand Down