diff --git a/platform/chromium/manifest.json b/platform/chromium/manifest.json index 6cfbfcf94..c7a94a19d 100644 --- a/platform/chromium/manifest.json +++ b/platform/chromium/manifest.json @@ -1,77 +1,89 @@ { - "manifest_version": 2, - - "name": "uBlock Origin", - "version": "1.15.11.0", - - "commands": { - "launch-element-zapper": { - "description": "__MSG_popupTipZapper__" - }, - "launch-element-picker": { - "description": "__MSG_popupTipPicker__" - }, - "launch-logger": { - "description": "__MSG_popupTipLog__" - } + "author": "All uBlock Origin contributors", + "background": { + "page": "background.html" + }, + "browser_action": { + "default_icon": { + "19": "img/browsericons/icon19.png", + "38": "img/browsericons/icon38.png" }, - "default_locale": "en", - "description": "__MSG_extShortDesc__", - "icons": { - "16": "img/icon_16.png", - "128": "img/icon_128.png" + "default_title": "uBlock Origin", + "default_popup": "popup.html" + }, + "commands": { + "launch-element-zapper": { + "description": "__MSG_popupTipZapper__" }, - - "browser_action": { - "default_icon": { - "19": "img/browsericons/icon19.png", - "38": "img/browsericons/icon38.png" - }, - "default_title": "uBlock Origin", - "default_popup": "popup.html" + "launch-element-picker": { + "description": "__MSG_popupTipPicker__" }, - - "author": "All uBlock Origin contributors", - "background": { - "page": "background.html" + "launch-logger": { + "description": "__MSG_popupTipLog__" + } + }, + "content_scripts": [ + { + "matches": [ + "http://*/*", + "https://*/*" + ], + "js": [ + "/js/vapi.js", + "/js/vapi-client.js", + "/js/contentscript.js" + ], + "run_at": "document_start", + "all_frames": true }, - "content_scripts": [ - { - "matches": ["http://*/*", "https://*/*"], - "js": ["/js/vapi.js", "/js/vapi-client.js", "/js/contentscript.js"], - "run_at": "document_start", - "all_frames": true - }, - { - "matches": ["http://*/*", "https://*/*"], - "js": ["/js/scriptlets/subscriber.js"], - "run_at": "document_idle", - "all_frames": false - } - ], - "incognito": "split", - "minimum_chrome_version": "45.0", - "optional_permissions": [ "file:///*" ], - "options_page": "dashboard.html", - "options_ui": { - "page": "options_ui.html" - }, - "permissions": [ - "contextMenus", - "privacy", - "storage", - "tabs", - "unlimitedStorage", - "webNavigation", - "webRequest", - "webRequestBlocking", - "" - ], - "short_name": "uBlock₀", - "storage": { - "managed_schema": "managed_storage.json" - }, - "web_accessible_resources": [ - "/web_accessible_resources/*" - ] + { + "matches": [ + "http://*/*", + "https://*/*" + ], + "js": [ + "/js/scriptlets/subscriber.js" + ], + "run_at": "document_idle", + "all_frames": false + } + ], + "default_locale": "en", + "description": "__MSG_extShortDesc__", + "icons": { + "16": "img/icon_16.png", + "32": "img/icon_32.png", + "64": "img/icon_64.png", + "128": "img/icon_128.png" + }, + "incognito": "split", + "manifest_version": 2, + "minimum_chrome_version": "45.0", + "name": "uBlock Origin", + "optional_permissions": [ + "file:///*" + ], + "options_page": "dashboard.html", + "options_ui": { + "page": "options_ui.html" + }, + "permissions": [ + "contextMenus", + "privacy", + "storage", + "tabs", + "unlimitedStorage", + "webNavigation", + "webRequest", + "webRequestBlocking", + "" + ], + "short_name": "uBlock₀", + "storage": { + "managed_schema": "managed_storage.json" + }, + "version": "1.15.11.0", + "web_accessible_resources": [ + "/web_accessible_resources/*" + ] } diff --git a/platform/debian/manifest.json b/platform/debian/manifest.json new file mode 100644 index 000000000..39b65e8f3 --- /dev/null +++ b/platform/debian/manifest.json @@ -0,0 +1,105 @@ +{ + "applications": { + "gecko": { + "id": "uBlock0-webext@raymondhill.net", + "strict_min_version": "52.0" + } + }, + "author": "All uBlock Origin contributors", + "background": { + "page": "background.html" + }, + "browser_action": { + "browser_style": false, + "default_icon": { + "19": "img/browsericons/icon19.png", + "38": "img/browsericons/icon38.png" + }, + "default_title": "uBlock Origin", + "default_popup": "popup.html" + }, + "commands": { + "launch-element-zapper": { + "description": "__MSG_popupTipZapper__" + }, + "launch-element-picker": { + "description": "__MSG_popupTipPicker__" + }, + "launch-logger": { + "description": "__MSG_popupTipLog__" + } + }, + "content_scripts": [ + { + "matches": [ + "http://*/*", + "https://*/*", + "file://*/*" + ], + "js": [ + "/js/vapi.js", + "/js/vapi-client.js", + "/js/contentscript.js" + ], + "run_at": "document_start", + "all_frames": true + }, + { + "matches": [ + "http://*/*", + "https://*/*" + ], + "js": [ + "/js/scriptlets/subscriber.js" + ], + "run_at": "document_idle", + "all_frames": false + } + ], + "default_locale": "en", + "description": "__MSG_extShortDesc__", + "icons": { + "16": "img/icon_16.png", + "32": "img/icon_32.png", + "64": "img/icon_64.png", + "128": "img/icon_128.png" + }, + "incognito": "split", + "manifest_version": 2, + "minimum_chrome_version": "45.0", + "name": "uBlock Origin", + "optional_permissions": [ + "file:///*" + ], + "options_ui": { + "page": "dashboard.html", + "open_in_tab": true + }, + "permissions": [ + "contextMenus", + "privacy", + "storage", + "tabs", + "unlimitedStorage", + "webNavigation", + "webRequest", + "webRequestBlocking", + "" + ], + "short_name": "uBlock₀", + "sidebar_action": { + "default_title": "__MSG_statsPageName__", + "default_panel": "logger-ui.html", + "default_icon": { + "16": "img/ublock.svg", + "48": "img/ublock.svg" + } + }, + "storage": { + "managed_schema": "managed_storage.json" + }, + "version": "1.9.15.101", + "web_accessible_resources": [ + "/web_accessible_resources/*" + ] +} diff --git a/platform/debian/vapi-webrequest.js b/platform/debian/vapi-webrequest.js new file mode 100644 index 000000000..a388adcc0 --- /dev/null +++ b/platform/debian/vapi-webrequest.js @@ -0,0 +1,176 @@ +/******************************************************************************* + + uBlock Origin - a browser extension to block requests. + Copyright (C) 2018 Raymond Hill + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 this program. If not, see {http://www.gnu.org/licenses/}. + + Home: https://github.com/gorhill/uBlock +*/ + +// For background page + +'use strict'; + +/******************************************************************************/ + +vAPI.net = { + onBeforeRequest: {}, + onBeforeMaybeSpuriousCSPReport: {}, + onHeadersReceived: {}, + nativeCSPReportFiltering: true, + webRequest: chrome.webRequest, + canFilterResponseBody: + typeof chrome.webRequest === 'object' && + typeof chrome.webRequest.filterResponseData === 'function' +}; + +/******************************************************************************/ + +vAPI.net.registerListeners = function() { + + let wrApi = chrome.webRequest; + + // legacy Chromium understands only these network request types. + let validTypes = new Set([ + 'image', + 'main_frame', + 'object', + 'other', + 'script', + 'stylesheet', + 'sub_frame', + 'xmlhttprequest', + ]); + // modern Chromium/WebExtensions: more types available. + if ( wrApi.ResourceType ) { + for ( let typeKey in wrApi.ResourceType ) { + if ( wrApi.ResourceType.hasOwnProperty(typeKey) ) { + validTypes.add(wrApi.ResourceType[typeKey]); + } + } + } + + let denormalizeTypes = function(aa) { + if ( aa.length === 0 ) { + return Array.from(validTypes); + } + let out = new Set(), + i = aa.length; + while ( i-- ) { + let type = aa[i]; + if ( validTypes.has(type) ) { + out.add(type); + } + if ( type === 'image' && validTypes.has('imageset') ) { + out.add('imageset'); + } + } + return Array.from(out); + }; + + let normalizeRequestDetails = function(details) { + if ( details.tabId === vAPI.noTabId ) { + // Chromium uses `initiator` property. + if ( + details.documentUrl === undefined && + typeof details.initiator === 'string' + ) { + details.documentUrl = details.initiator; + } + if ( typeof details.documentUrl === 'string' ) { + details.tabId = vAPI.anyTabId; + } + } + + // https://github.com/gorhill/uBlock/issues/1493 + // Chromium 49+/WebExtensions support a new request type: `ping`, + // which is fired as a result of using `navigator.sendBeacon`. + if ( details.type === 'ping' ) { + details.type = 'beacon'; + return; + } + + if ( details.type === 'imageset' ) { + details.type = 'image'; + return; + } + }; + + let onBeforeRequestClient = this.onBeforeRequest.callback; + let onBeforeRequest = function(details) { + normalizeRequestDetails(details); + return onBeforeRequestClient(details); + }; + + if ( onBeforeRequest ) { + let urls = this.onBeforeRequest.urls || ['']; + let types = this.onBeforeRequest.types || undefined; + if ( + (validTypes.has('websocket')) && + (types === undefined || types.indexOf('websocket') !== -1) && + (urls.indexOf('') === -1) + ) { + if ( urls.indexOf('ws://*/*') === -1 ) { + urls.push('ws://*/*'); + } + if ( urls.indexOf('wss://*/*') === -1 ) { + urls.push('wss://*/*'); + } + } + wrApi.onBeforeRequest.addListener( + onBeforeRequest, + { urls: urls, types: types }, + this.onBeforeRequest.extra + ); + } + + // https://github.com/gorhill/uBlock/issues/3140 + if ( typeof this.onBeforeMaybeSpuriousCSPReport.callback === 'function' ) { + wrApi.onBeforeRequest.addListener( + this.onBeforeMaybeSpuriousCSPReport.callback, + { + urls: [ 'http://*/*', 'https://*/*' ], + types: [ 'csp_report' ] + }, + [ 'blocking', 'requestBody' ] + ); + } + + let onHeadersReceivedClient = this.onHeadersReceived.callback, + onHeadersReceivedClientTypes = this.onHeadersReceived.types.slice(0), + onHeadersReceivedTypes = denormalizeTypes(onHeadersReceivedClientTypes); + let onHeadersReceived = function(details) { + normalizeRequestDetails(details); + if ( + onHeadersReceivedClientTypes.length !== 0 && + onHeadersReceivedClientTypes.indexOf(details.type) === -1 + ) { + return; + } + return onHeadersReceivedClient(details); + }; + + if ( onHeadersReceived ) { + let urls = this.onHeadersReceived.urls || ['']; + let types = onHeadersReceivedTypes; + wrApi.onHeadersReceived.addListener( + onHeadersReceived, + { urls: urls, types: types }, + this.onHeadersReceived.extra + ); + } +}; + +/******************************************************************************/ diff --git a/platform/opera/manifest.json b/platform/opera/manifest.json index 07e956c80..d6656c927 100644 --- a/platform/opera/manifest.json +++ b/platform/opera/manifest.json @@ -51,8 +51,10 @@ "default_locale": "en", "description": "__MSG_extShortDesc__", "icons": { - "128": "img/icon_128.png", - "16": "img/icon_16.png" + "16": "img/icon_16.png", + "32": "img/icon_32.png", + "64": "img/icon_64.png", + "128": "img/icon_128.png" }, "incognito": "split", "manifest_version": 2, @@ -73,7 +75,7 @@ "webRequestBlocking", "" ], - "short_name": "uBlock\u2080", + "short_name": "uBlock₀", "sidebar_action": { "default_icon": { "19": "img/browsericons/icon19.png", diff --git a/platform/webext/manifest.json b/platform/webext/manifest.json index 1e8cc2678..70619abca 100644 --- a/platform/webext/manifest.json +++ b/platform/webext/manifest.json @@ -1,95 +1,95 @@ { - "applications":{ - "gecko":{ - "id":"uBlock0@raymondhill.net", - "strict_min_version":"52.0" - } - }, - "author":"All uBlock Origin contributors", - "background":{ - "page":"background.html" - }, - "browser_action":{ - "browser_style":false, - "default_icon":{ - "19":"img/browsericons/icon19.png", - "38":"img/browsericons/icon38.png" - }, - "default_title":"uBlock Origin", - "default_popup":"popup.html" - }, - "commands":{ - "launch-element-zapper":{ - "description":"__MSG_popupTipZapper__" - }, - "launch-element-picker":{ - "description":"__MSG_popupTipPicker__" - }, - "launch-logger":{ - "description":"__MSG_popupTipLog__" - } - }, - "content_scripts":[ - { - "matches":[ - "http://*/*", - "https://*/*", - "file://*/*" - ], - "js":[ - "/js/vapi.js", - "/js/vapi-client.js", - "/js/contentscript.js" - ], - "run_at":"document_start", - "all_frames":true - }, - { - "matches":[ - "http://*/*", - "https://*/*" - ], - "js":[ - "/js/scriptlets/subscriber.js" - ], - "run_at":"document_idle", - "all_frames":false - } - ], - "default_locale":"en", - "description":"__MSG_extShortDesc__", - "icons":{ - "16":"img/ublock.svg", - "48":"img/ublock.svg", - "96":"img/ublock.svg" - }, - "manifest_version":2, - "name":"uBlock Origin", - "options_ui":{ - "page":"dashboard.html", - "open_in_tab": true - }, - "permissions":[ - "contextMenus", - "privacy", - "storage", - "tabs", - "webNavigation", - "webRequest", - "webRequestBlocking", - "" - ], - "short_name":"uBlock₀", - "sidebar_action":{ - "default_title":"__MSG_statsPageName__", - "default_panel":"logger-ui.html", - "default_icon":{ - "16":"img/ublock.svg", - "48":"img/ublock.svg" - } - }, - "version":"1.9.15.101", - "web_accessible_resources": [ - "/web_accessible_resources/*" - ] + "applications": { + "gecko": { + "id": "uBlock0@raymondhill.net", + "strict_min_version": "52.0" + } + }, + "author": "All uBlock Origin contributors", + "background": { + "page": "background.html" + }, + "browser_action": { + "browser_style": false, + "default_icon": { + "19": "img/browsericons/icon19.png", + "38": "img/browsericons/icon38.png" + }, + "default_title": "uBlock Origin", + "default_popup": "popup.html" + }, + "commands": { + "launch-element-zapper": { + "description": "__MSG_popupTipZapper__" + }, + "launch-element-picker": { + "description": "__MSG_popupTipPicker__" + }, + "launch-logger": { + "description": "__MSG_popupTipLog__" + } + }, + "content_scripts": [ + { + "matches": [ + "http://*/*", + "https://*/*", + "file://*/*" + ], + "js": [ + "/js/vapi.js", + "/js/vapi-client.js", + "/js/contentscript.js" + ], + "run_at": "document_start", + "all_frames": true + }, + { + "matches": [ + "http://*/*", + "https://*/*" + ], + "js": [ + "/js/scriptlets/subscriber.js" + ], + "run_at": "document_idle", + "all_frames": false + } + ], + "default_locale": "en", + "description": "__MSG_extShortDesc__", + "icons": { + "16": "img/ublock.svg", + "48": "img/ublock.svg", + "96": "img/ublock.svg" + }, + "manifest_version": 2, + "name": "uBlock Origin", + "options_ui": { + "page": "dashboard.html", + "open_in_tab": true + }, + "permissions": [ + "contextMenus", + "privacy", + "storage", + "tabs", + "webNavigation", + "webRequest", + "webRequestBlocking", + "" + ], + "short_name": "uBlock₀", + "sidebar_action": { + "default_title": "__MSG_statsPageName__", + "default_panel": "logger-ui.html", + "default_icon": { + "16": "img/ublock.svg", + "48": "img/ublock.svg" + } + }, + "version": "1.9.15.101", + "web_accessible_resources": [ + "/web_accessible_resources/*" + ] } diff --git a/src/img/icon_32.png b/src/img/icon_32.png new file mode 100644 index 000000000..c7c93e39d Binary files /dev/null and b/src/img/icon_32.png differ diff --git a/src/img/icon_64.png b/src/img/icon_64.png new file mode 100644 index 000000000..50dcded67 Binary files /dev/null and b/src/img/icon_64.png differ diff --git a/tools/make-debian-meta.py b/tools/make-debian-meta.py new file mode 100644 index 000000000..6fc340f4a --- /dev/null +++ b/tools/make-debian-meta.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +import os +import json +import re +import sys + +if len(sys.argv) == 1 or not sys.argv[1]: + raise SystemExit('Build dir missing.') + +proj_dir = os.path.join(os.path.split(os.path.abspath(__file__))[0], '..') +build_dir = os.path.abspath(sys.argv[1]) + +version = '' +with open(os.path.join(proj_dir, 'dist', 'version')) as f: + version = f.read().strip() + +webext_manifest = {} +webext_manifest_file = os.path.join(build_dir, 'manifest.json') +with open(webext_manifest_file) as f2: + webext_manifest = json.load(f2) + +match = re.search('^(\d+\.\d+\.\d+)(\.\d+)$', version) +if match: + buildtype = int(match.group(2)[1:]) + if buildtype < 100: + builttype = 'b' + str(buildtype) + else: + builttype = 'rc' + str(buildtype - 100) + webext_manifest['version'] = match.group(1) + builttype +else: + webext_manifest['version'] = version + +with open(webext_manifest_file, 'w') as f2: + json.dump(webext_manifest, f2, indent=2, separators=(',', ': '), sort_keys=True) + f2.write('\n') diff --git a/tools/make-debian.sh b/tools/make-debian.sh new file mode 100755 index 000000000..0c3757b82 --- /dev/null +++ b/tools/make-debian.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# +# This script assumes a linux environment + +echo "*** uBlock0.debian: Creating web store package" +echo "*** uBlock0.debian: Copying files" + +DES=dist/build/uBlock0.debian +rm -rf $DES +mkdir -p $DES + +bash ./tools/make-assets.sh $DES + +cp -R src/css $DES/ +cp -R src/img $DES/ +cp -R src/js $DES/ +cp -R src/lib $DES/ +cp -R src/_locales $DES/ +cp -R $DES/_locales/nb $DES/_locales/no +cp src/*.html $DES/ +cp -R platform/chromium/img $DES/ +cp platform/chromium/*.js $DES/js/ +cp platform/chromium/*.html $DES/ +cp platform/chromium/*.json $DES/ +cp LICENSE.txt $DES/ + +cp platform/debian/manifest.json $DES/ +cp platform/debian/vapi-usercss.js $DES/js/ +cp platform/debian/vapi-webrequest.js $DES/js/ + +echo "*** uBlock0.debian: concatenating content scripts" +cat $DES/js/vapi-usercss.js > /tmp/contentscript.js +echo >> /tmp/contentscript.js +grep -v "^'use strict';$" $DES/js/vapi-usercss.real.js >> /tmp/contentscript.js +echo >> /tmp/contentscript.js +grep -v "^'use strict';$" $DES/js/vapi-usercss.pseudo.js >> /tmp/contentscript.js +echo >> /tmp/contentscript.js +grep -v "^'use strict';$" $DES/js/contentscript.js >> /tmp/contentscript.js +mv /tmp/contentscript.js $DES/js/contentscript.js +rm $DES/js/vapi-usercss.js +rm $DES/js/vapi-usercss.real.js +rm $DES/js/vapi-usercss.pseudo.js + +echo "*** uBlock0.debian: Generating web accessible resources..." +cp -R src/web_accessible_resources $DES/ +python3 tools/import-war.py $DES/ + +echo "*** uBlock0.debian: Generating meta..." +python tools/make-debian-meta.py $DES/ + +if [ "$1" = all ]; then + echo "*** uBlock0.debian: Creating package..." + pushd $DES > /dev/null + zip ../$(basename $DES).xpi -qr * + popd > /dev/null +fi + +echo "*** uBlock0.debian: Package done." diff --git a/tools/make-webext.sh b/tools/make-webext.sh index 4a1648673..dffc7db04 100755 --- a/tools/make-webext.sh +++ b/tools/make-webext.sh @@ -25,7 +25,6 @@ cp platform/chromium/*.json $DES/ cp LICENSE.txt $DES/ cp platform/webext/manifest.json $DES/ -cp platform/webext/polyfill.js $DES/js/ cp platform/webext/vapi-usercss.js $DES/js/ cp platform/webext/vapi-webrequest.js $DES/js/