diff --git a/src/js/scriptlet-filtering.js b/src/js/scriptlet-filtering.js index 2e24181b2..b12825dea 100644 --- a/src/js/scriptlet-filtering.js +++ b/src/js/scriptlet-filtering.js @@ -69,15 +69,16 @@ return; } let injectScriptlets = function(d) { - let script = d.createElement('script'); + let script; try { + script = d.createElement('script'); script.appendChild(d.createTextNode( decodeURIComponent(scriptlets)) ); (d.head || d.documentElement).appendChild(script); } catch (ex) { } - if ( script.parentNode ) { + if ( script && script.parentNode ) { script.parentNode.removeChild(script); } }; diff --git a/src/js/tab.js b/src/js/tab.js index 56b3ffcfc..177697c0e 100644 --- a/src/js/tab.js +++ b/src/js/tab.js @@ -494,7 +494,10 @@ vAPI.tabs.onNavigation = function(details) { } } if ( µb.canInjectScriptletsNow ) { - µb.scriptletFilteringEngine.injectNow(details); + let pageStore = µb.pageStoreFromTabId(details.tabId); + if ( pageStore !== null && pageStore.getNetFilteringSwitch() ) { + µb.scriptletFilteringEngine.injectNow(details); + } } }; @@ -505,12 +508,8 @@ vAPI.tabs.onNavigation = function(details) { // the extension icon won't be properly refreshed. vAPI.tabs.onUpdated = function(tabId, changeInfo, tab) { - if ( !tab.url || tab.url === '' ) { - return; - } - if ( !changeInfo.url ) { - return; - } + if ( !tab.url || tab.url === '' ) { return; } + if ( !changeInfo.url ) { return; } µb.tabContextManager.commit(tabId, changeInfo.url); µb.bindTabToPageStats(tabId, 'tabUpdated'); };