From e8730f68798f173bd4d1c2f9b7ce02985e3fd771 Mon Sep 17 00:00:00 2001 From: Ruben Rodriguez Date: Fri, 1 Sep 2017 16:35:50 -0400 Subject: SpyBlock updated to 2.9.1 --- .../chrome/content/elemHideEmulation.js | 167 +++++++++ .../spyblock@gnu.org/chrome/content/errors.html | 111 ------ .../spyblock@gnu.org/chrome/content/objtabs.css | 2 +- .../spyblock@gnu.org/chrome/content/ui/common.js | 154 ++++++++ .../spyblock@gnu.org/chrome/content/ui/composer.js | 54 ++- .../chrome/content/ui/composer.xul | 2 +- .../chrome/content/ui/ext/common.js | 187 ++++------ .../chrome/content/ui/ext/content.js | 116 +++--- .../chrome/content/ui/fennecSettings.xul | 4 +- .../chrome/content/ui/filters-backup.js | 115 +++--- .../chrome/content/ui/filters-filteractions.js | 43 ++- .../chrome/content/ui/filters-filterview.js | 114 +++--- .../chrome/content/ui/filters-search.js | 226 +++++------- .../content/ui/filters-subscriptionactions.js | 12 +- .../chrome/content/ui/filters-subscriptionview.js | 42 ++- .../spyblock@gnu.org/chrome/content/ui/filters.js | 5 +- .../spyblock@gnu.org/chrome/content/ui/filters.xul | 31 +- .../chrome/content/ui/firstRun.html | 93 ++--- .../spyblock@gnu.org/chrome/content/ui/firstRun.js | 212 ++--------- .../spyblock@gnu.org/chrome/content/ui/flasher.js | 108 ------ .../spyblock@gnu.org/chrome/content/ui/i18n.js | 89 +++-- .../spyblock@gnu.org/chrome/content/ui/overlay.xul | 26 +- .../chrome/content/ui/progressBar.js | 2 +- .../chrome/content/ui/progressBar.xul | 2 +- .../chrome/content/ui/sendReport.js | 340 +++++++++--------- .../chrome/content/ui/sendReport.xul | 9 +- .../chrome/content/ui/settings.xul | 4 +- .../spyblock@gnu.org/chrome/content/ui/sidebar.js | 388 ++++++++++++--------- .../spyblock@gnu.org/chrome/content/ui/sidebar.xul | 7 +- .../chrome/content/ui/sidebarDetached.xul | 2 +- .../chrome/content/ui/skin/abb-logo.png | Bin 0 -> 1309 bytes .../chrome/content/ui/skin/abp-128.png | Bin 7303 -> 7768 bytes .../chrome/content/ui/skin/common.css | 59 ++++ .../chrome/content/ui/skin/features/malware.png | Bin 3335 -> 0 bytes .../chrome/content/ui/skin/features/social.png | Bin 4260 -> 0 bytes .../chrome/content/ui/skin/features/tracking.png | Bin 3562 -> 0 bytes .../chrome/content/ui/skin/firstRun.css | 350 +++++++------------ .../chrome/content/ui/subscriptionSelection.js | 6 +- .../chrome/content/ui/subscriptionSelection.xul | 2 +- .../chrome/content/ui/subscriptions.xml | 53 ++- .../spyblock@gnu.org/chrome/content/ui/utils.js | 28 +- 41 files changed, 1556 insertions(+), 1609 deletions(-) create mode 100644 data/extensions/spyblock@gnu.org/chrome/content/elemHideEmulation.js delete mode 100644 data/extensions/spyblock@gnu.org/chrome/content/errors.html create mode 100644 data/extensions/spyblock@gnu.org/chrome/content/ui/common.js delete mode 100644 data/extensions/spyblock@gnu.org/chrome/content/ui/flasher.js create mode 100644 data/extensions/spyblock@gnu.org/chrome/content/ui/skin/abb-logo.png create mode 100644 data/extensions/spyblock@gnu.org/chrome/content/ui/skin/common.css delete mode 100644 data/extensions/spyblock@gnu.org/chrome/content/ui/skin/features/malware.png delete mode 100644 data/extensions/spyblock@gnu.org/chrome/content/ui/skin/features/social.png delete mode 100644 data/extensions/spyblock@gnu.org/chrome/content/ui/skin/features/tracking.png (limited to 'data/extensions/spyblock@gnu.org/chrome/content') diff --git a/data/extensions/spyblock@gnu.org/chrome/content/elemHideEmulation.js b/data/extensions/spyblock@gnu.org/chrome/content/elemHideEmulation.js new file mode 100644 index 0000000..ff824ae --- /dev/null +++ b/data/extensions/spyblock@gnu.org/chrome/content/elemHideEmulation.js @@ -0,0 +1,167 @@ +// We are currently limited to ECMAScript 5 in this file, because it is being +// used in the browser tests. See https://issues.adblockplus.org/ticket/4796 + +var propertySelectorRegExp = /\[\-abp\-properties=(["'])([^"']+)\1\]/; + +function splitSelector(selector) +{ + if (selector.indexOf(",") == -1) + return [selector]; + + var selectors = []; + var start = 0; + var level = 0; + var sep = ""; + + for (var i = 0; i < selector.length; i++) + { + var chr = selector[i]; + + if (chr == "\\") // ignore escaped characters + i++; + else if (chr == sep) // don't split within quoted text + sep = ""; // e.g. [attr=","] + else if (sep == "") + { + if (chr == '"' || chr == "'") + sep = chr; + else if (chr == "(") // don't split between parentheses + level++; // e.g. :matches(div,span) + else if (chr == ")") + level = Math.max(0, level - 1); + else if (chr == "," && level == 0) + { + selectors.push(selector.substring(start, i)); + start = i + 1; + } + } + } + + selectors.push(selector.substring(start)); + return selectors; +} + +function ElemHideEmulation(window, getFiltersFunc, addSelectorsFunc) +{ + this.window = window; + this.getFiltersFunc = getFiltersFunc; + this.addSelectorsFunc = addSelectorsFunc; +} + +ElemHideEmulation.prototype = { + stringifyStyle: function(style) + { + var styles = []; + for (var i = 0; i < style.length; i++) + { + var property = style.item(i); + var value = style.getPropertyValue(property); + var priority = style.getPropertyPriority(property); + styles.push(property + ": " + value + (priority ? " !" + priority : "") + ";"); + } + styles.sort(); + return styles.join(" "); + }, + + isSameOrigin: function(stylesheet) + { + try + { + return new URL(stylesheet.href).origin == this.window.location.origin; + } + catch (e) + { + // Invalid URL, assume that it is first-party. + return true; + } + }, + + findSelectors: function(stylesheet, selectors, filters) + { + // Explicitly ignore third-party stylesheets to ensure consistent behavior + // between Firefox and Chrome. + if (!this.isSameOrigin(stylesheet)) + return; + + var rules = stylesheet.cssRules; + if (!rules) + return; + + for (var i = 0; i < rules.length; i++) + { + var rule = rules[i]; + if (rule.type != rule.STYLE_RULE) + continue; + + var style = this.stringifyStyle(rule.style); + for (var j = 0; j < this.patterns.length; j++) + { + var pattern = this.patterns[j]; + if (pattern.regexp.test(style)) + { + var subSelectors = splitSelector(rule.selectorText); + for (var k = 0; k < subSelectors.length; k++) + { + var subSelector = subSelectors[k]; + selectors.push(pattern.prefix + subSelector + pattern.suffix); + filters.push(pattern.text); + } + } + } + } + }, + + addSelectors: function(stylesheets) + { + var selectors = []; + var filters = []; + for (var i = 0; i < stylesheets.length; i++) + this.findSelectors(stylesheets[i], selectors, filters); + this.addSelectorsFunc(selectors, filters); + }, + + onLoad: function(event) + { + var stylesheet = event.target.sheet; + if (stylesheet) + this.addSelectors([stylesheet]); + }, + + apply: function() + { + this.getFiltersFunc(function(patterns) + { + this.patterns = []; + for (var i = 0; i < patterns.length; i++) + { + var pattern = patterns[i]; + var match = propertySelectorRegExp.exec(pattern.selector); + if (!match) + continue; + + var propertyExpression = match[2]; + var regexpString; + if (propertyExpression.length >= 2 && propertyExpression[0] == "/" && + propertyExpression[propertyExpression.length - 1] == "/") + regexpString = propertyExpression.slice(1, -1) + .replace("\\x7B ", "{").replace("\\x7D ", "}"); + else + regexpString = filterToRegExp(propertyExpression); + + this.patterns.push({ + text: pattern.text, + regexp: new RegExp(regexpString, "i"), + prefix: pattern.selector.substr(0, match.index), + suffix: pattern.selector.substr(match.index + match[0].length) + }); + } + + if (this.patterns.length > 0) + { + var document = this.window.document; + this.addSelectors(document.styleSheets); + document.addEventListener("load", this.onLoad.bind(this), true); + } + }.bind(this)); + } +}; diff --git a/data/extensions/spyblock@gnu.org/chrome/content/errors.html b/data/extensions/spyblock@gnu.org/chrome/content/errors.html deleted file mode 100644 index 24e05a5..0000000 --- a/data/extensions/spyblock@gnu.org/chrome/content/errors.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - Adblock Plus Errors - - - - - - - - - diff --git a/data/extensions/spyblock@gnu.org/chrome/content/objtabs.css b/data/extensions/spyblock@gnu.org/chrome/content/objtabs.css index d61f702..62ad04b 100644 --- a/data/extensions/spyblock@gnu.org/chrome/content/objtabs.css +++ b/data/extensions/spyblock@gnu.org/chrome/content/objtabs.css @@ -1,6 +1,6 @@ /* * This file is part of Adblock Plus , - * Copyright (C) 2006-2015 Eyeo GmbH + * Copyright (C) 2006-2017 eyeo GmbH * * Adblock Plus is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as diff --git a/data/extensions/spyblock@gnu.org/chrome/content/ui/common.js b/data/extensions/spyblock@gnu.org/chrome/content/ui/common.js new file mode 100644 index 0000000..ec20ede --- /dev/null +++ b/data/extensions/spyblock@gnu.org/chrome/content/ui/common.js @@ -0,0 +1,154 @@ +/* + * This file is part of Adblock Plus , + * Copyright (C) 2006-2017 eyeo GmbH + * + * Adblock Plus is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * Adblock Plus is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Adblock Plus. If not, see . + */ + +/* globals Components */ + +"use strict"; + +function E(id) +{ + return document.getElementById(id); +} + +function getDocLink(link, callback) +{ + ext.backgroundPage.sendMessage({ + type: "app.get", + what: "doclink", + link + }, callback); +} + +function checkShareResource(url, callback) +{ + ext.backgroundPage.sendMessage({ + type: "filters.blocked", + url, + requestType: "SCRIPT", + docDomain: "adblockplus.org", + thirdParty: true + }, callback); +} + +function openSharePopup(url) +{ + let glassPane = E("glass-pane"); + if (!glassPane) + { + glassPane = document.createElement("div"); + glassPane.setAttribute("id", "glass-pane"); + document.body.appendChild(glassPane); + } + + let iframe = E("share-popup"); + if (!iframe) + { + iframe = document.createElement("iframe"); + iframe.setAttribute("id", "share-popup"); + iframe.setAttribute("scrolling", "no"); + glassPane.appendChild(iframe); + } + + // Firefox 38+ no longer allows messaging using postMessage so we need + // to have a fake top level frame to avoid problems with scripts that try to + // communicate with the first-run page + let isGecko = ("Components" in window); + if (isGecko) + { + try + { + let Ci = Components.interfaces; + let docShell = iframe.contentWindow + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDocShell); + + if (typeof docShell.frameType != "undefined") + { + // Gecko 47+ + docShell.frameType = docShell.FRAME_TYPE_BROWSER; + } + else + { + // Legacy branch + docShell.setIsBrowserInsideApp( + Ci.nsIScriptSecurityManager.UNKNOWN_APP_ID + ); + } + } + catch (ex) + { + console.error(ex); + } + } + + let popupMessageReceived = false; + function resizePopup(width, height) + { + iframe.width = width; + iframe.height = height; + iframe.style.marginTop = -height / 2 + "px"; + iframe.style.marginLeft = -width / 2 + "px"; + popupMessageReceived = true; + window.removeEventListener("message", popupMessageListener); + } + + let popupMessageListener = function(event) + { + if (!/[./]adblockplus\.org$/.test(event.origin) || + !("width" in event.data) || !("height" in event.data)) + return; + + resizePopup(event.data.width, event.data.height); + }; + // Firefox requires last parameter to be true to be triggered by + // unprivileged pages + window.addEventListener("message", popupMessageListener, false, true); + + let popupLoadListener = function() + { + if (!popupMessageReceived && isGecko) + { + let rootElement = iframe.contentDocument.documentElement; + let {width, height} = rootElement.dataset; + if (width && height) + resizePopup(width, height); + } + + if (popupMessageReceived) + { + iframe.className = "visible"; + + let popupCloseListener = function() + { + iframe.className = glassPane.className = ""; + document.removeEventListener("click", popupCloseListener); + }; + document.addEventListener("click", popupCloseListener, false); + } + else + { + glassPane.className = ""; + window.removeEventListener("message", popupMessageListener); + } + + iframe.removeEventListener("load", popupLoadListener); + }; + iframe.addEventListener("load", popupLoadListener, false); + + iframe.src = url; + glassPane.className = "visible"; +} diff --git a/data/extensions/spyblock@gnu.org/chrome/content/ui/composer.js b/data/extensions/spyblock@gnu.org/chrome/content/ui/composer.js index 98a38aa..8170cee 100644 --- a/data/extensions/spyblock@gnu.org/chrome/content/ui/composer.js +++ b/data/extensions/spyblock@gnu.org/chrome/content/ui/composer.js @@ -1,6 +1,6 @@ /* * This file is part of Adblock Plus , - * Copyright (C) 2006-2015 Eyeo GmbH + * Copyright (C) 2006-2017 eyeo GmbH * * Adblock Plus is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as @@ -15,13 +15,14 @@ * along with Adblock Plus. If not, see . */ -let nodes = null; -let item = null; -let advancedMode = false; +var nodesID = null; +var item = null; +var advancedMode = false; function init() { - [nodes, item] = window.arguments; + [nodesID, item] = window.arguments; + window.addEventListener("unload", () => Policy.deleteNodes(nodesID)); E("filterType").value = (!item.filter || item.filter.disabled || item.filter instanceof WhitelistFilter ? "filterlist" : "whitelist"); E("customPattern").value = item.location; @@ -118,19 +119,8 @@ function init() else E("patternGroup").focus(); - let types = []; - for (let type in Policy.localizedDescr) - { - types.push(parseInt(type)); - } - types.sort(function(a, b) { - if (a < b) - return -1; - else if (a > b) - return 1; - else - return 0; - }); + let types = Array.from(new Set(Policy.contentTypes.values())); + types.sort(); let docDomain = item.docDomain; let thirdParty = item.thirdParty; @@ -145,24 +135,24 @@ function init() let typeGroup = E("typeGroup"); let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMap.DOCUMENT; - let isDefaultType = (RegExpFilter.typeMap[item.typeDescr] & defaultTypes) != 0; + let isDefaultType = (RegExpFilter.typeMap[item.type] & defaultTypes) != 0; for (let type of types) { - if (type == Policy.type.ELEMHIDE) + if (type == "ELEMHIDE" || type == "GENERICBLOCK" || type == "GENERICHIDE") continue; let typeNode = document.createElement("checkbox"); - typeNode.setAttribute("value", Policy.typeDescr[type].toLowerCase().replace(/\_/g, "-")); - typeNode.setAttribute("label", Policy.localizedDescr[type].toLowerCase()); + typeNode.setAttribute("value", type.toLowerCase().replace(/\_/g, "-")); + typeNode.setAttribute("label", Utils.getString("type_label_" + type.toLowerCase())); - let typeMask = RegExpFilter.typeMap[Policy.typeDescr[type]]; + let typeMask = RegExpFilter.typeMap[type]; typeNode._defaultType = (typeMask & defaultTypes) != 0; if ((isDefaultType && typeNode._defaultType) || (!isDefaultType && item.type == type)) typeNode.setAttribute("checked", "true"); if (item.type == type) typeNode.setAttribute("disabled", "true"); - typeNode.addEventListener("command", function() checkboxUpdated(this), false); + typeNode.addEventListener("command", () => checkboxUpdated(typeNode), false); typeGroup.appendChild(typeNode); } @@ -255,16 +245,16 @@ function updateFilter() if (options.length) { - options.sort(function(a, b) a[0] - b[0]); - filter += "$" + options.map(function(o) o[1]).join(","); + options.sort((a, b) => a[0] - b[0]); + filter += "$" + options.map(o => o[1]).join(","); } } else { let defaultTypes = RegExpFilter.prototype.contentType & ~RegExpFilter.typeMap.DOCUMENT; - let isDefaultType = (RegExpFilter.typeMap[item.typeDescr] & defaultTypes) != 0; + let isDefaultType = (RegExpFilter.typeMap[item.type] & defaultTypes) != 0; if (!isDefaultType) - filter += "$" + item.typeDescr.toLowerCase().replace(/\_/g, "-"); + filter += "$" + item.type.toLowerCase().replace(/\_/g, "-"); } filter = Filter.normalize(filter); @@ -279,7 +269,7 @@ function updateFilter() } E("shortpatternWarning").hidden = !isSlow; - E("matchWarning").hidden = compiledFilter instanceof RegExpFilter && compiledFilter.matches(item.location, item.typeDescr, item.docDomain, item.thirdParty); + E("matchWarning").hidden = compiledFilter instanceof RegExpFilter && compiledFilter.matches(item.location, RegExpFilter.typeMap[item.type], item.docDomain, item.thirdParty); E("filter").value = filter; } @@ -318,7 +308,7 @@ function updatePatternSelection() function testFilter(/**String*/ filter) /**Boolean*/ { - return RegExpFilter.fromText(filter + "$" + item.typeDescr).matches(item.location, item.typeDescr, item.docDomain, item.thirdParty); + return RegExpFilter.fromText(filter + "$" + item.type).matches(item.location, RegExpFilter.typeMap[item.type], item.docDomain, item.thirdParty); } let anchorStartCheckbox = E("anchorStart"); @@ -352,8 +342,8 @@ function addFilter() { FilterStorage.addFilter(filter); - if (nodes) - Policy.refilterNodes(nodes, item); + if (nodesID) + Policy.refilterNodes(nodesID, item); return true; } diff --git a/data/extensions/spyblock@gnu.org/chrome/content/ui/composer.xul b/data/extensions/spyblock@gnu.org/chrome/content/ui/composer.xul index 66e64ef..2cf1502 100644 --- a/data/extensions/spyblock@gnu.org/chrome/content/ui/composer.xul +++ b/data/extensions/spyblock@gnu.org/chrome/content/ui/composer.xul @@ -2,7 +2,7 @@ -