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: Check platform and platform version for user stylesheet support Created April 20, 2017, 12:42 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
« no previous file with comments | « include.preload.js ('k') | metadata.chrome » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 */
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" &&
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 "";
47
48 try
kzar 2017/04/21 11:20:22 I guess we don't really need this try catch here a
Manish Jethani 2017/04/21 13:39:32 Removed.
49 {
50 chrome.tabs.insertCSS(tabId,
51 {
kzar 2017/04/21 11:20:22 Nit: We'd normally put the semicolon on the above
kzar 2017/04/21 11:21:57 Arg, of course I meant `{` not `;`! Like this chr
Manish Jethani 2017/04/21 13:39:32 It did pass linting. I've seen this style in many
kzar 2017/04/21 14:36:51 I'll defer to Sebastian there.
52 code,
53 cssOrigin: "user",
54 frameId,
55 matchAboutBlank: true
56 },
57 () =>
58 {
59 callback(chrome.runtime.lastError);
60 }
61 );
62 }
63 catch (error)
64 {
65 callback(error);
66 }
67 };
OLDNEW
« no previous file with comments | « include.preload.js ('k') | metadata.chrome » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld