Skip to content

Commit

Permalink
added tab_event (blocking event on new tab for resolving #58)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaliiiiiiiiii committed Jul 17, 2023
1 parent aeb1956 commit 1998a33
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/selenium_profiles/files/proxy_extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,36 @@ chrome.webRequest.onAuthRequired.addListener(
{urls: ["<all_urls>"]},
['blocking']
);

globalThis.tab_event = {checked_tabs:[],tab_callback:undefined}

tab_event.req_callback = function(details) {
var tab_id = details['tabId']
if(tab_id >= 0){
if(!(tab_event.checked_tabs.includes(tab_id))){
tab_event.tab_callback(details)
tab_event.checked_tabs.push(tab_id)
}
}
else{console.log(details);}
return {};
}

tab_event.on_tab_removed = function(tabId) {
var idx= tab_event.checked_tabs.indexOf(tabId);
tab_event.checked_tabs = tab_event.checked_tabs.splice(idx, 1);
}

tab_event.set_listener = function(callback){
tab_event.tab_callback = callback
if(!(tab_event.tab_callback)){
chrome.webRequest.onBeforeRequest.addListener(
tab_event.req_callback,
{urls: ["<all_urls>"]},
["blocking"]
);
chrome.tabs.onRemoved.addListener(tab_event.on_tab_removed)
}
}


0 comments on commit 1998a33

Please sign in to comment.