1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-05 11:37:01 +02:00

complete "debian" as a target platform

This commit is contained in:
Raymond Hill 2018-04-27 11:43:35 -04:00
parent d0c1c7c4c9
commit 08495c42e9
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
10 changed files with 556 additions and 168 deletions

View File

@ -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",
"<all_urls>"
],
"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",
"<all_urls>"
],
"short_name": "uBlock₀",
"storage": {
"managed_schema": "managed_storage.json"
},
"version": "1.15.11.0",
"web_accessible_resources": [
"/web_accessible_resources/*"
]
}

View File

@ -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",
"<all_urls>"
],
"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/*"
]
}

View File

@ -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 || ['<all_urls>'];
let types = this.onBeforeRequest.types || undefined;
if (
(validTypes.has('websocket')) &&
(types === undefined || types.indexOf('websocket') !== -1) &&
(urls.indexOf('<all_urls>') === -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 || ['<all_urls>'];
let types = onHeadersReceivedTypes;
wrApi.onHeadersReceived.addListener(
onHeadersReceived,
{ urls: urls, types: types },
this.onHeadersReceived.extra
);
}
};
/******************************************************************************/

View File

@ -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",
"<all_urls>"
],
"short_name": "uBlock\u2080",
"short_name": "uBlock",
"sidebar_action": {
"default_icon": {
"19": "img/browsericons/icon19.png",

View File

@ -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",
"<all_urls>"
],
"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",
"<all_urls>"
],
"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/*"
]
}

BIN
src/img/icon_32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
src/img/icon_64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

36
tools/make-debian-meta.py Normal file
View File

@ -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')

58
tools/make-debian.sh Executable file
View File

@ -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."

View File

@ -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/