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

Unified Diff: lib/cssInjection.js

Issue 29564767: Issue 242 - Use user style sheets on Chromium (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Rebase and update target version Created Oct. 20, 2017, 12:41 a.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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/cssInjection.js
===================================================================
--- a/lib/cssInjection.js
+++ b/lib/cssInjection.js
@@ -21,29 +21,37 @@
const {RegExpFilter} = require("filterClasses");
const {ElemHide} = require("elemHide");
const {ElemHideEmulation} = require("elemHideEmulation");
const {checkWhitelisted} = require("whitelisting");
const {extractHostFromFrame} = require("url");
const {port} = require("messaging");
const devtools = require("devtools");
+const info = require("info");
-const userStyleSheetsSupported = "extensionTypes" in browser &&
- "CSSOrigin" in browser.extensionTypes;
+const cssOriginSupported = "extensionTypes" in browser &&
+ "CSSOrigin" in browser.extensionTypes;
+const userStyleSheetsSupported = cssOriginSupported ||
+ (info.platform == "chromium" &&
+ parseInt(info.platformVersion, 10) >= 64);
function hideElements(tabId, frameId, selectors)
{
- browser.tabs.insertCSS(tabId, {
+ let options = {
code: selectors.join(", ") + "{display: none !important;}",
- cssOrigin: "user",
frameId,
matchAboutBlank: true,
runAt: "document_start"
- });
+ };
+
+ if (cssOriginSupported)
+ options.cssOrigin = "user";
+
+ browser.tabs.insertCSS(tabId, options);
}
port.on("elemhide.getSelectors", (msg, sender) =>
{
let selectors = [];
let emulatedPatterns = [];
let trace = devtools && devtools.hasPanel(sender.page);
let inject = !userStyleSheetsSupported;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld