@ -726,31 +726,32 @@ if (typeof browser !== 'object') {
ext _api . tabs . onUpdated . addListener ( ( tabId , changeInfo , tab ) => {
if ( changeInfo . status === 'complete' && /^http/ . test ( tab . url ) && matchUrlDomain ( enabledSites , tab . url ) ) {
let url = tab . url ;
let rc _domain = matchUrlDomain ( remove _cookies , url ) ;
let rc _domain _enabled = rc _domain && enabledSites . includes ( rc _domain ) ;
let lib _file = 'lib/empty.js' ;
if ( matchUrlDomain ( dompurify _sites , url ) )
lib _file = 'lib/purify.min.js' ;
var bg2csData = {
optin _setcookie : optin _setcookie ,
amp _unhide : matchUrlDomain ( amp _unhide , url )
} ;
let amp _redirect _domain = '' ;
if ( amp _redirect _domain = matchUrlDomain ( Object . keys ( amp _redirect ) , url ) )
bg2csData . amp _redirect = amp _redirect [ amp _redirect _domain ] ;
let cs _code _domain = '' ;
if ( cs _code _domain = matchUrlDomain ( Object . keys ( cs _code ) , url ) )
bg2csData . cs _code = cs _code [ cs _code _domain ] ;
let ld _json _domain = '' ;
if ( ld _json _domain = matchUrlDomain ( Object . keys ( ld _json ) , url ) )
bg2csData . ld _json = ld _json [ ld _json _domain ] ;
let ld _google _webcache _domain = '' ;
if ( ld _google _webcache _domain = matchUrlDomain ( Object . keys ( ld _google _webcache ) , url ) )
bg2csData . ld _google _webcache = ld _google _webcache [ ld _google _webcache _domain ] ;
let tab _runs = 5 ;
for ( let n = 0 ; n < tab _runs ; n ++ ) {
let url = tab . url ;
let rc _domain = matchUrlDomain ( remove _cookies , url ) ;
let rc _domain _enabled = rc _domain && enabledSites . includes ( rc _domain ) ;
let lib _file = 'lib/empty.js' ;
if ( matchUrlDomain ( dompurify _sites , url ) )
lib _file = 'lib/purify.min.js' ;
var bg2csData = {
optin _setcookie : optin _setcookie ,
amp _unhide : matchUrlDomain ( amp _unhide , url )
} ;
let amp _redirect _domain = '' ;
if ( amp _redirect _domain = matchUrlDomain ( Object . keys ( amp _redirect ) , url ) )
bg2csData . amp _redirect = amp _redirect [ amp _redirect _domain ] ;
let cs _code _domain = '' ;
if ( cs _code _domain = matchUrlDomain ( Object . keys ( cs _code ) , url ) )
bg2csData . cs _code = cs _code [ cs _code _domain ] ;
let ld _json _domain = '' ;
if ( ld _json _domain = matchUrlDomain ( Object . keys ( ld _json ) , url ) )
bg2csData . ld _json = ld _json [ ld _json _domain ] ;
let ld _google _webcache _domain = '' ;
if ( ld _google _webcache _domain = matchUrlDomain ( Object . keys ( ld _google _webcache ) , url ) )
bg2csData . ld _google _webcache = ld _google _webcache [ ld _google _webcache _domain ] ;
setTimeout ( function ( ) {
// run contentScript.js on page
ext _api . tabs . executeScript ( tabId , {
code : 'var bg2csData = ' + JSON . stringify ( bg2csData ) + ';'
} , function ( ) {
@ -768,12 +769,26 @@ ext_api.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
} )
} ) ;
} ) ;
// remove cookies after page load
if ( rc _domain _enabled ) {
remove _cookies _fn ( rc _domain , true ) ;
}
} , n * 1000 / tab _runs ) ;
}
}
if ( changeInfo . status === 'complete' ) {
// load toggleIcon.js (icon for dark or incognito mode in Chrome))
if ( typeof browser !== 'object' ) {
ext _api . tabs . executeScript ( tabId , {
file : 'options/toggleIcon.js' ,
runAt : 'document_start'
} , function ( res ) {
if ( ext _api . runtime . lastError || res [ 0 ] ) {
return ;
}
} ) ;
}
}
} ) ;
setInterval ( function ( ) {
@ -1010,25 +1025,6 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
}
}
// load toggleIcon.js (icon for dark or incognito mode in Chrome))
if ( typeof browser !== 'object' && [ 'main_frame' , 'xmlhttprequest' ] . includes ( details . type ) ) {
ext _api . tabs . query ( {
active : true ,
currentWindow : true
} , function ( tabs ) {
if ( tabs && tabs [ 0 ] && tabs [ 0 ] . url && tabs [ 0 ] . url . startsWith ( 'http' ) ) {
ext _api . tabs . executeScript ( {
file : 'options/toggleIcon.js' ,
runAt : 'document_start'
} , function ( res ) {
if ( ext _api . runtime . lastError || res [ 0 ] ) {
return ;
}
} ) ;
}
} ) ;
}
if ( ! isSiteEnabled ( details ) ) {
return ;
}