Index: background.js |
diff --git a/background.js b/background.js |
index cb7a861be117f6a390b74ffa1370bb9de50ba33f..243628d159da0c23fab35de53715324de3113d60 100644 |
--- a/background.js |
+++ b/background.js |
@@ -21,6 +21,7 @@ const {RegExpFilter} = require("filterClasses"); |
const {ElemHide} = require("elemHide"); |
const {checkWhitelisted} = require("whitelisting"); |
const {extractHostFromFrame} = require("url"); |
+const {userStylesheetsSupported, hideElements} = require("css"); |
const {port} = require("messaging"); |
const devtools = require("devtools"); |
@@ -45,7 +46,32 @@ port.on("get-selectors", (msg, sender) => |
selectors = []; |
} |
- return {selectors, trace}; |
+ if (!userStylesheetsSupported) |
+ return {selectors, trace, inject: true}; |
+ |
+ return new Promise(resolve => |
+ { |
+ hideElements(sender.page.id, sender.frame.id, selectors, error => |
+ { |
+ let response = {trace, inject: !!error}; |
+ |
+ if (trace || error) |
+ response.selectors = selectors; |
+ |
+ resolve(response); |
+ }); |
+ }); |
+}); |
+ |
+port.on("hide-elements", (msg, sender) => |
+{ |
+ return new Promise(resolve => |
+ { |
+ hideElements(sender.page.id, sender.frame.id, msg.selectors, error => |
+ { |
+ resolve({success: !error}); |
+ }); |
+ }); |
}); |
port.on("forward", (msg, sender) => |