Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: background.js

Issue 29410607: Issue 5090 - Use user stylesheets for element hiding if possible (Closed)
Patch Set: Remove try/catch Created April 21, 2017, 1:34 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ext/background.js » ('j') | include.preload.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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};
Sebastian Noack 2017/04/29 22:11:03 How about moving this message handler (i.e. this f
Manish Jethani 2017/05/01 23:18:05 Done, there is now a elemHideHelper module that ha
+ 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) =>
« no previous file with comments | « no previous file | ext/background.js » ('j') | include.preload.js » ('J')

Powered by Google App Engine
This is Rietveld