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

Side by Side Diff: lib/css.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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 /** @module css */
Sebastian Noack 2017/04/29 22:11:03 I feel "css" being a too generic name for what is
Manish Jethani 2017/05/01 23:18:05 Done.
19
20 "use strict";
21
22 const info = require("info");
23
24 /**
25 * Whether user stylesheets are supported on this platform.
26 *
27 * @type {boolean}
28 * @static
29 */
30 exports.userStylesheetsSupported = info.platform == "gecko" &&
Sebastian Noack 2017/04/29 22:11:04 Again, please avoid statically binding logic to th
Manish Jethani 2017/05/01 23:18:05 I had used feature detection originally, but then
Wladimir Palant 2017/05/17 11:50:16 Given that the values provided by the info module
31 info.platformVersion.split(".")[0] >= 53;
32
33 /**
34 * Hides elements on the page using the browser.tabs.insertCSS API.
35 *
36 * @param {string} tabId The ID of the tab in which to hide elements
37 * @param {string} frameId The ID of the frame in which to hide elements
38 * @param {string[]} selectors The list of selectors for the elements to hide
39 * @param {Function} callback The function to be called upon completion
40 * @static
41 */
42 exports.hideElements = (tabId, frameId, selectors, callback) =>
43 {
44 let code = selectors.length > 0 ?
45 selectors.join(", ") + "{display: none !important;}" :
46 "";
Sebastian Noack 2017/04/29 22:11:03 Is this function under any circumstances called wi
Manish Jethani 2017/05/01 23:18:05 Done.
47
48 chrome.tabs.insertCSS(tabId,
49 {
50 code,
51 cssOrigin: "user",
52 frameId,
53 matchAboutBlank: true
54 },
55 () =>
56 {
57 callback(chrome.runtime.lastError);
58 }
59 );
60 };
OLDNEW
« include.preload.js ('K') | « include.preload.js ('k') | metadata.chrome » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld