@@ -74,18 +74,14 @@ browser.storage.onChanged.addListener((changes, areaName) => {
7474
7575const redirectedToTwitch = { } ;
7676
77+
7778console . log ( 'location' , window . location . href ) ;
7879
7980browser . tabs . onUpdated . addListener ( ( tabId , changeInfo , tab ) => {
8081 if ( changeInfo . status === 'loading' && changeInfo . url ) {
8182 console . log ( 'changeInfo' , changeInfo ) ;
82- if (
83- ! redirectedToTwitch [ tabId ] &&
84- // if redirecting within twitch
85- twitchUrlRegexp . test ( changeInfo . url )
86- // // or reloading the twitch page
87- // || !changeInfo.url && twitchUrlRegexp.test(tab.url)
88- ) {
83+ // if redirecting within twitch
84+ if ( ! redirectedToTwitch [ tabId ] && twitchUrlRegexp . test ( changeInfo . url ) ) {
8985 console . log ( 'valid url' , ( changeInfo || tab ) . url ) ;
9086 unlockForTab ( tabId ) ;
9187 redirectedToTwitch [ tabId ] = true ;
@@ -105,6 +101,12 @@ browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
105101 }
106102} ) ;
107103
104+ browser . tabs . onRemoved . addListener ( ( tabId ) => {
105+ if ( redirectedToTwitch [ tabId ] ) {
106+ delete redirectedToTwitch [ tabId ] ;
107+ }
108+ } )
109+
108110// browser.runtime.onMessage.addListener((message, sender) => {
109111// console.log('sender', sender);
110112// console.log('message', message);
0 commit comments