Skip to content

Commit

Permalink
changed active tab handler
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverWang13 committed May 5, 2024
1 parent 7ce7c5f commit 015d905
Showing 1 changed file with 17 additions and 3 deletions.
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

0 comments on commit 015d905

Please sign in to comment.