Index: lib/filterComposer.js |
=================================================================== |
--- a/lib/filterComposer.js |
+++ b/lib/filterComposer.js |
@@ -21,16 +21,17 @@ |
const {defaultMatcher} = require("matcher"); |
const {RegExpFilter} = require("filterClasses"); |
const {FilterNotifier} = require("filterNotifier"); |
const {Prefs} = require("prefs"); |
const {extractHostFromFrame, stringifyURL, isThirdParty} = require("url"); |
const {getKey, checkWhitelisted} = require("whitelisting"); |
const {port} = require("messaging"); |
+const info = require("info"); |
let readyPages = new ext.PageMap(); |
/** |
* Checks whether the given page is ready to use the filter composer |
* |
* @param {Page} page |
* @return {boolean} |
@@ -179,30 +180,40 @@ |
page.contextMenus.remove(contextMenuItem); |
if (typeof filter == "undefined") |
filter = checkWhitelisted(page); |
if (!filter && Prefs.shouldShowBlockElementMenu && readyPages.has(page)) |
page.contextMenus.create(contextMenuItem); |
} |
+function shouldDisable() |
+{ |
+ // Disable the composer if the browser is unknown or if it's |
Manish Jethani
2017/08/15 23:50:06
We have to cover null and "unknown" as well, becau
|
+ // "Fennec" (Firefox for Android). |
+ return !info.application || info.application == "unknown" || |
+ info.application == "fennec"; |
+} |
+ |
FilterNotifier.on("page.WhitelistingStateRevalidate", updateContextMenu); |
Prefs.on("shouldShowBlockElementMenu", () => |
{ |
ext.pages.query({}, pages => |
{ |
for (let page of pages) |
updateContextMenu(page); |
}); |
}); |
port.on("composer.ready", (message, sender) => |
{ |
- readyPages.set(sender.page, null); |
+ if (!shouldDisable()) |
+ readyPages.set(sender.page, null); |
+ |
updateContextMenu(sender.page); |
}); |
port.on("composer.openDialog", (message, sender) => |
{ |
return new Promise(resolve => |
{ |
ext.windows.create({ |
@@ -251,10 +262,13 @@ |
port.on("composer.quoteCSS", (message, sender) => |
{ |
return quoteCSS(message.CSS); |
}); |
ext.pages.onLoading.addListener(page => |
{ |
+ if (shouldDisable()) |
Manish Jethani
2017/08/15 23:50:06
If we simply cut off the communication between com
|
+ return; |
+ |
page.sendMessage({type: "composer.content.finished"}); |
}); |