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: Created Oct. 4, 2017, 10:32 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 | 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 chrome &&
- "CSSOrigin" in chrome.extensionTypes;
+const cssOriginSupported = "extensionTypes" in chrome &&
+ "CSSOrigin" in chrome.extensionTypes;
+const userStyleSheetsSupported = cssOriginSupported ||
+ (info.platform == "chromium" &&
+ parseInt(info.platformVersion, 10) >= 60);
function hideElements(tabId, frameId, selectors)
{
- chrome.tabs.insertCSS(tabId, {
+ let options = {
code: selectors.join(", ") + "{display: none !important;}",
- cssOrigin: "user",
frameId,
matchAboutBlank: true,
runAt: "document_start"
- });
+ };
+
+ if (cssOriginSupported)
+ options.cssOrigin = "user";
+
+ chrome.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