From 08495c42e9dd3e027479bf61a55169c8dd08aa25 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 27 Apr 2018 11:43:35 -0400 Subject: [PATCH] complete "debian" as a target platform --- platform/chromium/manifest.json | 154 +++++++++++++----------- platform/debian/manifest.json | 105 ++++++++++++++++ platform/debian/vapi-webrequest.js | 176 +++++++++++++++++++++++++++ platform/opera/manifest.json | 8 +- platform/webext/manifest.json | 186 ++++++++++++++--------------- src/img/icon_32.png | Bin 0 -> 1278 bytes src/img/icon_64.png | Bin 0 -> 2655 bytes tools/make-debian-meta.py | 36 ++++++ tools/make-debian.sh | 58 +++++++++ tools/make-webext.sh | 1 - 10 files changed, 556 insertions(+), 168 deletions(-) create mode 100644 platform/debian/manifest.json create mode 100644 platform/debian/vapi-webrequest.js create mode 100644 src/img/icon_32.png create mode 100644 src/img/icon_64.png create mode 100644 tools/make-debian-meta.py create mode 100755 tools/make-debian.sh 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 0000000000000000000000000000000000000000..c7c93e39df5e6a062b3a94453072713474e67a71 GIT binary patch literal 1278 zcmVk=oOp$->Jj5jqgl2(^2Y2B4xY?Td>x1)wYdWfO_Q*Nw*R$2V`v)?1H=H_=B_<`sY@e%%75xF%_Pj4dz!>{Re;o@RT43G6EoN(`Y=;-EO)_ zC=dWBDjvT$hDm^vnMuE9$>o$`U?86$2rqjnMg@I7Dl{___mZqj6ot^t4E_4j@23Ee z0Kkf*fFL$#xND18^rDsl5Ss`9VsYh{0W1YKM=aLL8CVK#ikOywWU*MUnUc*E1vA61 zArhBpG%z@wI2{b)bT9}*e?Mf^)oTHeZvuqbX=w|IjHdq19Y{19B=dMk=J6n@ti%^R zJ6b&$!!smw*0U#F^@TzTLV;@#hQg~?}&@%ucDJda<)kMWO%2`ofG(a+!`+_Msa)h!u96HA4a_Q%f z>g!kZDLHx+0N@)QW(0`#q5(MR>3*iRdQ?i?tR#6XNakQ(L1rh`J^KTOH4%a+RqQ7VTb=F0#8K%!Fp6urYYT5K*CIVx3GbZi-bqM_lU z{P5wsZwo+CUw^l>q2Xdo0D>UMqMDlHxfK#d9Gb6b#-+7IM&t0e4xjv!n(Q#GM(;g#i2v@ znA%spht1r-pXqWqY@_Y%U%vGD*0npgh{dlI217@QUT+c<7YAbH#dQ&U(AxUh#I0N3 zJ#sjTDUw`0nIItDx6fU;f4{k`vGM1%YR7#O_4#~h<97SEkFH)dycio3G3C6obLUji zfdlOYjg8G>v3M@t+Ut_{_U-(>rlu>lZQH_@r9Y=up>Y1X(b(8e!C84#tdQ(G5$#%6`&GU|o{Msub;>gSL z#j5D*>+^bCR8)8}A)z}Rpy>cT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-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/