code review for c5d85881181a: mind whitelist status; mind an inaccessible document

This commit is contained in:
Raymond Hill 2018-05-22 09:26:49 -04:00
parent b6b1edb288
commit f887eeb3f5
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 9 additions and 9 deletions

View File

@ -69,15 +69,16 @@
return; return;
} }
let injectScriptlets = function(d) { let injectScriptlets = function(d) {
let script = d.createElement('script'); let script;
try { try {
script = d.createElement('script');
script.appendChild(d.createTextNode( script.appendChild(d.createTextNode(
decodeURIComponent(scriptlets)) decodeURIComponent(scriptlets))
); );
(d.head || d.documentElement).appendChild(script); (d.head || d.documentElement).appendChild(script);
} catch (ex) { } catch (ex) {
} }
if ( script.parentNode ) { if ( script && script.parentNode ) {
script.parentNode.removeChild(script); script.parentNode.removeChild(script);
} }
}; };

View File

@ -494,7 +494,10 @@ vAPI.tabs.onNavigation = function(details) {
} }
} }
if ( µb.canInjectScriptletsNow ) { 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. // the extension icon won't be properly refreshed.
vAPI.tabs.onUpdated = function(tabId, changeInfo, tab) { vAPI.tabs.onUpdated = function(tabId, changeInfo, tab) {
if ( !tab.url || tab.url === '' ) { if ( !tab.url || tab.url === '' ) { return; }
return; if ( !changeInfo.url ) { return; }
}
if ( !changeInfo.url ) {
return;
}
µb.tabContextManager.commit(tabId, changeInfo.url); µb.tabContextManager.commit(tabId, changeInfo.url);
µb.bindTabToPageStats(tabId, 'tabUpdated'); µb.bindTabToPageStats(tabId, 'tabUpdated');
}; };