From 152cea2dfe9d0e35d86314633d612a9ad96ee94f Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Wed, 3 Jul 2019 09:40:12 -0400 Subject: [PATCH] Refactor management of injectable resources This is a first step, the ultimate goal is to remove the need for resources.txt, or at least to reduce to only hotfixes or for trivial resources targeting very specific websites. Most resources will become immutable, i.e. they will be part of uBO's code base. Advantages include easier code maintenance (jshint, syntax highlight), and to make scriptlets more easy to code review by external parties (for example extension store reviewers). TODO: - More scriptlets need to be imported before next release. - Need to make legacy versions of uBO use a legacy version of resources.txt, as all the now obsolete scriptlets will have to be removed once uBO's next release become widespread. - Possibly need to add code to load binary resources so that they can be injected as data: URI. So far it's unclear whether this is really needed. For example, this would be needed if a xmlhttprequest is redirected to an image resource. --- src/js/redirect-engine.js | 291 ++++++++++++++---- src/js/start.js | 13 +- src/js/storage.js | 26 +- src/web_accessible_resources/1x1.gif | Bin 0 -> 43 bytes src/web_accessible_resources/2x2.png | Bin 0 -> 68 bytes src/web_accessible_resources/32x32.png | Bin 0 -> 83 bytes src/web_accessible_resources/3x2.png | Bin 0 -> 68 bytes .../abort-current-inline-script.js | 79 +++++ .../abort-on-property-read.js | 72 +++++ .../abort-on-property-write.js | 50 +++ .../addthis_widget.js | 38 +++ src/web_accessible_resources/amazon_ads.js | 70 +++++ src/web_accessible_resources/ampproject_v0.js | 34 ++ src/web_accessible_resources/chartbeat.js | 30 ++ src/web_accessible_resources/disqus_embed.js | 42 +++ .../disqus_forums_embed.js | 52 ++++ .../doubleclick_instream_ad_status.js | 1 + src/web_accessible_resources/fookadblock.js | 63 ++++ .../google-analytics_analytics.js | 70 +++++ .../google-analytics_cx_api.js | 36 +++ .../google-analytics_ga.js | 118 +++++++ .../google-analytics_inpage_linkid.js | 28 ++ .../googlesyndication_adsbygoogle.js | 47 +++ .../googletagmanager_gtm.js | 43 +++ .../googletagservices_gpt.js | 149 +++++++++ src/web_accessible_resources/hd-main.js | 46 +++ src/web_accessible_resources/imported.txt | 10 - .../ligatus_angular-tag.js | 29 ++ src/web_accessible_resources/monkeybroker.js | 43 +++ src/web_accessible_resources/noeval-silent.js | 26 ++ src/web_accessible_resources/noop-0.1s.mp3 | Bin 0 -> 813 bytes src/web_accessible_resources/noop-1s.mp4 | Bin 0 -> 3753 bytes src/web_accessible_resources/noop.html | 5 + src/web_accessible_resources/noop.js | 3 + src/web_accessible_resources/noop.txt | 1 + .../outbrain-widget.js | 47 +++ src/web_accessible_resources/popads-dummy.js | 30 ++ src/web_accessible_resources/popads.js | 40 +++ .../scorecardresearch_beacon.js | 31 ++ src/web_accessible_resources/set-constant.js | 99 ++++++ .../setTimeout-defuser.js | 44 +++ src/web_accessible_resources/to-import.txt | 57 ---- src/web_accessible_resources/webrtc-if.js | 87 ++++++ tools/make-chromium.sh | 19 +- tools/make-firefox.sh | 18 +- tools/make-opera.sh | 19 +- tools/make-thunderbird.sh | 18 +- tools/make-webext.sh | 18 +- 48 files changed, 1820 insertions(+), 222 deletions(-) create mode 100644 src/web_accessible_resources/1x1.gif create mode 100644 src/web_accessible_resources/2x2.png create mode 100644 src/web_accessible_resources/32x32.png create mode 100644 src/web_accessible_resources/3x2.png create mode 100644 src/web_accessible_resources/abort-current-inline-script.js create mode 100644 src/web_accessible_resources/abort-on-property-read.js create mode 100644 src/web_accessible_resources/abort-on-property-write.js create mode 100644 src/web_accessible_resources/addthis_widget.js create mode 100644 src/web_accessible_resources/amazon_ads.js create mode 100644 src/web_accessible_resources/ampproject_v0.js create mode 100644 src/web_accessible_resources/chartbeat.js create mode 100644 src/web_accessible_resources/disqus_embed.js create mode 100644 src/web_accessible_resources/disqus_forums_embed.js create mode 100644 src/web_accessible_resources/doubleclick_instream_ad_status.js create mode 100644 src/web_accessible_resources/fookadblock.js create mode 100644 src/web_accessible_resources/google-analytics_analytics.js create mode 100644 src/web_accessible_resources/google-analytics_cx_api.js create mode 100644 src/web_accessible_resources/google-analytics_ga.js create mode 100644 src/web_accessible_resources/google-analytics_inpage_linkid.js create mode 100644 src/web_accessible_resources/googlesyndication_adsbygoogle.js create mode 100644 src/web_accessible_resources/googletagmanager_gtm.js create mode 100644 src/web_accessible_resources/googletagservices_gpt.js create mode 100644 src/web_accessible_resources/hd-main.js delete mode 100644 src/web_accessible_resources/imported.txt create mode 100644 src/web_accessible_resources/ligatus_angular-tag.js create mode 100644 src/web_accessible_resources/monkeybroker.js create mode 100644 src/web_accessible_resources/noeval-silent.js create mode 100644 src/web_accessible_resources/noop-0.1s.mp3 create mode 100644 src/web_accessible_resources/noop-1s.mp4 create mode 100644 src/web_accessible_resources/noop.html create mode 100644 src/web_accessible_resources/noop.js create mode 100644 src/web_accessible_resources/noop.txt create mode 100644 src/web_accessible_resources/outbrain-widget.js create mode 100644 src/web_accessible_resources/popads-dummy.js create mode 100644 src/web_accessible_resources/popads.js create mode 100644 src/web_accessible_resources/scorecardresearch_beacon.js create mode 100644 src/web_accessible_resources/set-constant.js create mode 100644 src/web_accessible_resources/setTimeout-defuser.js delete mode 100644 src/web_accessible_resources/to-import.txt create mode 100644 src/web_accessible_resources/webrtc-if.js diff --git a/src/js/redirect-engine.js b/src/js/redirect-engine.js index 6a938b356..e9819e63a 100644 --- a/src/js/redirect-engine.js +++ b/src/js/redirect-engine.js @@ -23,52 +23,166 @@ /******************************************************************************/ -µBlock.redirectEngine = (function(){ +µBlock.redirectEngine = (( ) => { /******************************************************************************/ /******************************************************************************/ -const warResolve = (function() { - let warPairs = []; +const immutableResources = new Map([ + [ '1x1.gif', { + alias: '1x1-transparent.gif', + inject: false + } ], + [ '2x2.png', { + alias: '2x2-transparent.png', + inject: false + } ], + [ '3x2.png', { + alias: '3x2-transparent.png', + inject: false + } ], + [ '32x32.png', { + alias: '32x32-transparent.png', + inject: false + } ], + [ 'abort-current-inline-script.js', { + alias: 'acis.js', + redirect: false + } ], + [ 'abort-on-property-read.js', { + alias: 'aopr.js', + redirect: false + } ], + [ 'abort-on-property-write.js', { + alias: 'aopw.js', + redirect: false + } ], + [ 'addthis_widget.js', { + alias: 'addthis.com/addthis_widget.js', + inject: false + } ], + [ 'ampproject_v0.js', { + alias: 'ampproject.org/v0.js', + inject: false + } ], + [ 'chartbeat.js', { + alias: 'static.chartbeat.com/chartbeat.js', + inject: false + } ], + [ 'amazon_ads.js', { + alias: 'amazon-adsystem.com/aax2/amzn_ads.js', + inject: false + } ], + [ 'disqus_embed.js', { + alias: 'disqus.com/embed.js', + inject: false + } ], + [ 'disqus_forums_embed.js', { + alias: 'disqus.com/forums/*/embed.js', + inject: false + } ], + [ 'doubleclick_instream_ad_status.js', { + alias: 'doubleclick.net/instream/ad_status.js', + inject: false + } ], + [ 'fookadblock.js', { + alias: 'fuckadblock.js-3.2.0', + } ], + [ 'google-analytics_analytics.js', { + alias: 'google-analytics.com/analytics.js', + inject: false + } ], + [ 'google-analytics_cx_api.js', { + alias: 'google-analytics.com/cx/api.js', + inject: false + } ], + [ 'google-analytics_ga.js', { + alias: 'google-analytics.com/ga.js', + inject: false + } ], + [ 'google-analytics_inpage_linkid.js', { + alias: 'google-analytics.com/inpage_linkid.js', + inject: false + } ], + [ 'googlesyndication_adsbygoogle.js', { + alias: 'googlesyndication.com/adsbygoogle.js', + inject: false + } ], + [ 'googletagmanager_gtm.js', { + alias: 'googletagmanager.com/gtm.js', + inject: false + } ], + [ 'googletagservices_gpt.js', { + alias: 'googletagservices.com/gpt.js', + inject: false + } ], + [ 'hd-main.js', { + inject: false + } ], + [ 'ligatus_angular-tag.js', { + alias: 'ligatus.com/*/angular-tag.js', + inject: false + } ], + [ 'monkeybroker.js', { + alias: 'd3pkae9owd2lcf.cloudfront.net/mb105.js', + inject: false + } ], + [ 'noeval-silent.js', { + alias: 'silent-noeval.js', + } ], + [ 'noop-0.1s.mp3', { + alias: 'noopmp3-0.1s', + inject: false + } ], + [ 'noop-1s.mp4', { + alias: 'noopmp4-1s', + inject: false + } ], + [ 'noop.html', { + alias: 'noopframe', + inject: false + } ], + [ 'noop.js', { + alias: 'noopjs', + } ], + [ 'noop.txt', { + alias: 'nooptext', + } ], + [ 'outbrain-widget.js', { + alias: 'widgets.outbrain.com/outbrain.js', + inject: false + } ], + [ 'popads.js', { + alias: 'popads.net.js', + } ], + [ 'popads-dummy.js', { + alias: 'popads-dummy.js', + } ], + [ 'scorecardresearch_beacon.js', { + alias: 'scorecardresearch.com/beacon.js', + inject: false + } ], + [ 'set-constant.js', { + redirect: false + } ], + [ 'setTimeout-defuser.js', { + alias: 'stod.js', + redirect: false + } ], + [ 'webrtc-if.js', { + redirect: false + } ], +]); - const onPairsReady = function() { - const reng = µBlock.redirectEngine; - for ( let i = 0; i < warPairs.length; i += 2 ) { - const resource = reng.resources.get(warPairs[i+0]); - if ( resource === undefined ) { continue; } - resource.warURL = vAPI.getURL( - '/web_accessible_resources/' + warPairs[i+1] - ); - } - reng.selfieFromResources(); - }; - - return function() { - if ( vAPI.warSecret === undefined || warPairs.length !== 0 ) { - return onPairsReady(); - } - - const onPairsLoaded = function(details) { - const marker = '>>>>>'; - const pos = details.content.indexOf(marker); - if ( pos === -1 ) { return; } - const pairs = details.content.slice(pos + marker.length) - .trim() - .split('\n'); - if ( (pairs.length & 1) !== 0 ) { return; } - for ( let i = 0; i < pairs.length; i++ ) { - pairs[i] = pairs[i].trim(); - } - warPairs = pairs; - onPairsReady(); - }; - - µBlock.assets.fetchText( - `/web_accessible_resources/imported.txt${vAPI.warSecret()}`, - onPairsLoaded - ); - }; -})(); +const mimeMap = { + gif: 'image/gif', + html: 'text/html', + js: 'application/javascript', + mp3: 'audio/mp3', + mp4: 'video/mp4', + png: 'image/png', + txt: 'text/plain', +}; // https://github.com/gorhill/uBlock/issues/3639 // https://github.com/EFForg/https-everywhere/issues/14961 @@ -107,6 +221,7 @@ RedirectEntry.prototype.toURL = function(fctxt) { ) { return `${this.warURL}${vAPI.warSecret()}`; } + if ( this.data === undefined ) { return; } if ( this.data.startsWith('data:') === false ) { if ( this.mime.indexOf(';') === -1 ) { this.data = 'data:' + this.mime + ';base64,' + btoa(this.data); @@ -134,9 +249,11 @@ RedirectEntry.prototype.toContent = function() { /******************************************************************************/ RedirectEntry.fromFields = function(mime, lines) { - var r = new RedirectEntry(); + const r = new RedirectEntry(); r.mime = mime; - r.data = lines.join(mime.indexOf(';') !== -1 ? '' : '\n'); + r.data = µBlock.orphanizeString( + lines.join(mime.indexOf(';') !== -1 ? '' : '\n') + ); return r; }; @@ -474,12 +591,13 @@ RedirectEngine.prototype.resourceContentFromName = function(name, mime) { // https://github.com/uBlockOrigin/uAssets/commit/deefe875551197d655f79cb540e62dfc17c95f42 // Consider 'none' a reserved keyword, to be used to disable redirection. -RedirectEngine.prototype.resourcesFromString = function(text) { - let fields, encoded, - reNonEmptyLine = /\S/, - lineIter = new µBlock.LineIterator(text); - - this.resources = new Map(); +RedirectEngine.prototype.resourcesFromString = function( + text, + override = true +) { + const lineIter = new µBlock.LineIterator(text); + const reNonEmptyLine = /\S/; + let fields, encoded; while ( lineIter.eot() === false ) { let line = lineIter.next(); @@ -500,10 +618,15 @@ RedirectEngine.prototype.resourcesFromString = function(text) { } // No more data, add the resource. - this.resources.set( - fields[0], - RedirectEntry.fromFields(fields[1], fields.slice(2)) - ); + if ( + this.resources.has(fields[0]) === false || + override !== false + ) { + this.resources.set( + fields[0], + RedirectEntry.fromFields(fields[1], fields.slice(2)) + ); + } fields = undefined; } @@ -516,13 +639,71 @@ RedirectEngine.prototype.resourcesFromString = function(text) { ); } - warResolve(); - this.modifyTime = Date.now(); }; /******************************************************************************/ +RedirectEngine.prototype.loadBuiltinResources = function() { + this.resources = new Map(); + const mimeFromName = function(name) { + const match = /\.([^.]+)$/.exec(name); + if ( match !== null ) { + return mimeMap[match[1]]; + } + }; + const fetches = [ + µBlock.assets.get('ublock-resources'), + ]; + for ( const [ name, details ] of immutableResources ) { + if ( details.inject !== false ) { + fetches.push( + µBlock.assets.fetchText( + `/web_accessible_resources/${name}${vAPI.warSecret()}` + ) + ); + continue; + } + const entry = RedirectEntry.fromSelfie({ + mime: mimeFromName(name), + warURL: vAPI.getURL(`/web_accessible_resources/${name}`), + }); + this.resources.set(name, entry); + if ( details.alias !== undefined ) { + this.resources.set(details.alias, entry); + } + } + return Promise.all(fetches).then(results => { + // Immutable resources + for ( let i = 1; i < results.length; i++ ) { + const result = results[i]; + const match = /^\/web_accessible_resources\/([^?]+)/.exec(result.url); + if ( match === null ) { continue; } + const name = match[1]; + const content = result.content.replace(/^\/\*[\S\s]+?\*\/\s*/, ''); + const details = immutableResources.get(name); + const entry = RedirectEntry.fromSelfie({ + mime: mimeFromName(name), + data: content, + warURL: details.redirect !== false + ? vAPI.getURL(`/web_accessible_resources/${name}`) + : undefined, + }); + this.resources.set(name, entry); + if ( details.alias !== undefined ) { + this.resources.set(details.alias, entry); + } + } + // Mutable resources + const content = results[0].content; + if ( typeof content === 'string' && content.length !== 0 ) { + this.resourcesFromString(content, false); + } + }); +}; + +/******************************************************************************/ + const resourcesSelfieVersion = 3; RedirectEngine.prototype.selfieFromResources = function() { diff --git a/src/js/start.js b/src/js/start.js index 8ec451ed5..97b20db13 100644 --- a/src/js/start.js +++ b/src/js/start.js @@ -177,15 +177,9 @@ const onCommandShortcutsReady = function(commandShortcuts) { const onVersionReady = function(lastVersion) { if ( lastVersion === vAPI.app.version ) { return; } - // Since AMO does not allow updating resources.txt, force a reload when a - // new version is detected, as resources.txt may have changed since last - // release. This will be done only for release versions of Firefox. - if ( - vAPI.webextFlavor.soup.has('firefox') && - vAPI.webextFlavor.soup.has('devbuild') === false - ) { - µb.redirectEngine.invalidateResourcesSelfie(); - } + // Since built-in resources may have changed since last version, we + // force a reload of all resources. + µb.redirectEngine.invalidateResourcesSelfie(); // If unused, just comment out for when we need to compare versions in the // future. @@ -320,7 +314,6 @@ const onFirstFetchReady = function(fetched) { µb.loadPublicSuffixList().then(( ) => { onPSLReady(); }); - µb.loadRedirectResources(); }; /******************************************************************************/ diff --git a/src/js/storage.js b/src/js/storage.js index 42cc67bc7..5da5421d5 100644 --- a/src/js/storage.js +++ b/src/js/storage.js @@ -987,9 +987,11 @@ µBlock.loadRedirectResources = function() { return this.redirectEngine.resourcesFromSelfie().then(success => { - if ( success === true ) { return; } + if ( success === true ) { return true; } - const fetchPromises = [ this.assets.get('ublock-resources') ]; + const fetchPromises = [ + this.redirectEngine.loadBuiltinResources() + ]; const userResourcesLocation = this.hiddenSettings.userResourcesLocation; if ( userResourcesLocation !== 'unset' ) { @@ -1000,11 +1002,11 @@ return Promise.all(fetchPromises); }).then(results => { - if ( Array.isArray(results) === false ) { return; } + if ( Array.isArray(results) === false ) { return results; } let content = ''; - - for ( const result of results ) { + for ( let i = 1; i < results.length; i++ ) { + const result = results[i]; if ( result instanceof Object === false || typeof result.content !== 'string' || @@ -1016,6 +1018,11 @@ } this.redirectEngine.resourcesFromString(content); + this.redirectEngine.selfieFromResources(); + return true; + }).catch(reason => { + log.info(reason); + return false; }); }; @@ -1109,9 +1116,12 @@ µb.redirectEngine.fromSelfie('selfie/redirectEngine'), µb.staticExtFilteringEngine.fromSelfie('selfie/staticExtFilteringEngine'), µb.staticNetFilteringEngine.fromSelfie('selfie/staticNetFilteringEngine'), - ]).then(results => - results.reduce((acc, v) => acc && v, true) - ).catch(reason => { + ]).then(results => { + if ( results.reduce((acc, v) => acc && v, true) ) { + return µb.loadRedirectResources(); + } + return false; + }).catch(reason => { log.info(reason); return false; }); diff --git a/src/web_accessible_resources/1x1.gif b/src/web_accessible_resources/1x1.gif new file mode 100644 index 0000000000000000000000000000000000000000..e565824aafafe632011b281cba976baf8b3ba89a GIT binary patch literal 43 qcmZ?wbhEHbWMp7uXkcLY4+e@qSs1y10y+#p0Fq%~V)9{Rum%7ZWeN!Z literal 0 HcmV?d00001 diff --git a/src/web_accessible_resources/2x2.png b/src/web_accessible_resources/2x2.png new file mode 100644 index 0000000000000000000000000000000000000000..3639dc75ab9fe6ff6d118c8ac2440aed5bc8eec9 GIT binary patch literal 68 zcmeAS@N?(olHy`uVBq!ia0vp^Od!m`1|*BN@u~nRZci7-5RU7~2@dQG3_=Wy?>j@5 Q0EHPmUHx3vIVCg!0BRBp)Bpeg literal 0 HcmV?d00001 diff --git a/src/web_accessible_resources/32x32.png b/src/web_accessible_resources/32x32.png new file mode 100644 index 0000000000000000000000000000000000000000..7bee0a002b75fb20e9b790068b7950121cdf779e GIT binary patch literal 83 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzDNh&2kch)?4>B?Wc})uc*XMaS cfSB*u1QZw;r+*K>4&*R+y85}Sb4q9e0KdKysQ>@~ literal 0 HcmV?d00001 diff --git a/src/web_accessible_resources/3x2.png b/src/web_accessible_resources/3x2.png new file mode 100644 index 0000000000000000000000000000000000000000..a056d8677db3e35cf6f1ec71d11bedccdb1d09f8 GIT binary patch literal 68 zcmeAS@N?(olHy`uVBq!ia0vp^%s|Y>>>> - diff --git a/src/web_accessible_resources/ligatus_angular-tag.js b/src/web_accessible_resources/ligatus_angular-tag.js new file mode 100644 index 000000000..5f4ab65f3 --- /dev/null +++ b/src/web_accessible_resources/ligatus_angular-tag.js @@ -0,0 +1,29 @@ +/******************************************************************************* + + uBlock Origin - a browser extension to block requests. + Copyright (C) 2019-present 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 +*/ + +(function() { + 'use strict'; + self.adProtect = true; + Object.defineProperties(window, { + uabpdl: { value: true }, + uabDetect: { value: true } + }); +})(); diff --git a/src/web_accessible_resources/monkeybroker.js b/src/web_accessible_resources/monkeybroker.js new file mode 100644 index 000000000..c121d5293 --- /dev/null +++ b/src/web_accessible_resources/monkeybroker.js @@ -0,0 +1,43 @@ +/******************************************************************************* + + uBlock Origin - a browser extension to block requests. + Copyright (C) 2019-present 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 +*/ + +(function() { + 'use strict'; + const noopfn = function() { + }; + window.pbjs = { libLoaded: true }; + const mb = window.MonkeyBroker || { + addAttribute: noopfn, + addSlot: function(a) { + this.slots[a.slot] = {}; + }, + defineSlot: noopfn, + fillSlot: noopfn, + go: noopfn, + inventoryConditionalPlacement: noopfn, + registerSizeCallback: noopfn, + registerSlotCallback: noopfn, + slots: {}, + version: '' + }; + mb.regSlotsMap = mb.slots; + window.MonkeyBroker = mb; +})(); diff --git a/src/web_accessible_resources/noeval-silent.js b/src/web_accessible_resources/noeval-silent.js new file mode 100644 index 000000000..1aa08cd3a --- /dev/null +++ b/src/web_accessible_resources/noeval-silent.js @@ -0,0 +1,26 @@ +/******************************************************************************* + + uBlock Origin - a browser extension to block requests. + Copyright (C) 2019-present 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 +*/ + +(function() { + 'use strict'; + window.eval = function() { + }.bind(window); +})(); diff --git a/src/web_accessible_resources/noop-0.1s.mp3 b/src/web_accessible_resources/noop-0.1s.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..147d71b0921f6079af834b2b1ea5a6b69316c558 GIT binary patch literal 813 zcmeZtF=k-^0p*b3U{@f`&%nU!lUSB!YNlsmpl4`c2$qEq|9^)d@vt*J^V0HxGC*S( z*nmbcFeIRX26V6h4IDrR575DXGyrl5(9Ov}H=7xNI540BV=yzEO<5W7|F=jA1OEpG zhD@M12Ll7I0s{jh5G?_6flQMI1_l-%M_*TCJxfbH(@>HD$b2~h=96qFk_M3ZHZ(Rr PipJ(w(AfNGG&COo>^AHA literal 0 HcmV?d00001 diff --git a/src/web_accessible_resources/noop-1s.mp4 b/src/web_accessible_resources/noop-1s.mp4 new file mode 100644 index 0000000000000000000000000000000000000000..5689d4a3c99916415a367854f05f28fcd4a0b54f GIT binary patch literal 3753 zcmds4UuYaf7@ypqw6<1TO>JvaothLMY%Y6uNty;0uPwC^trgow5bJercP_VN_ja?p zmt5-0i6RC2P%MVo`#$h;31PvIQv-L0a(-RuR#M_?z9k&E!mrAo}2t z-_AF`@0)LCzL{?(M+j*z`V-Ffo*_y|j2ND60U0)?r3oPmi!SGcw63sp=3hw=Vj6`a zV;W7TGW~>XCWmMuL$;ykJFUr?nYX^&dhLU6E)TwUc>N`Mx#Nc)tC_wY+C??nBq5?CsO~^?tB}DQLU5KfZNaR}bAZv;}55*Pz&9I};`^`ZS{`*{+O|7CuV8?+kQz zkB^V1#tfa?CM&0Gceq;&kt+F?2^-t-4ZG|OP>mIsrYh9sMKw!xUNCKKL`@GU0}5qj zW=?oqRjO!L)9Ey|xLV>>>QxGmHc-c#P}Aa@cXc(LQqTz>Y8h3o=Y>bnBk!{EFjv!k zR4ci*#q#KyroPKf)9@hmSNnC%#}u?t3tycxeV<+CY9_rNBNmzG=N)gva9~<@FzV#( zV$tKi+LfVx$wd!O?W3k`kFXLN`39G!o@r>9OM_5o*$u|f42$_<9!A;cuE}5ozF<~d zHj&qC%VEKc5F+1YMj0+(=rUnbbeY9HNaNfXF8L0m5k3L6n(1wbdCMrHNj;61xmNMj z9z~4gG7%M*dnI&owR|*Vp?5V^bBoj}AT(lTXsDTNN};1-KB|)HgXjpyLCvaa-$oFg z&mFagjupo87OT2qRU7*HgLa`(^o)I6%_`UwxDy8OgCH<7U&5A^5ocO7Op}YK7!I}y z#{xTv>9A3p07waH0$zu*W!qy|i)oFObktIbUnL~5fwU0u zH(Ta3KsU8>vzGHoaYEt>?wb)PpY}(BF~LQp?k#>TVj4ozIP;Es3dRS64xL>0JxJ}` z^!&ODc&Pgge8t|dbb~=hExmc|6@`$>W4q4=J-bS}>DGM^@p3g}Q4fiiY><_8+*N4C zcH$x|LTDSa0;lq{JM~c4uH&{9ol%7T){1M=P>$W{`2`d5+n(<=HbmH*sK4hBo0kse z6qY@RT0j(e)R1ZZuAG?x)djCxS~gEDnfZz=A4YvScJ{kOj*#DTWZ+2r+@hCTNV0U{ z`3n@r?Ujn5kCbxP^PM}+y}$9b)t|*Xeg-efO3x4CEo3qHJ@r_(VHsi{L=n6|J2*`c zC=ISrAAoLOs0zNq&+U*F*Rcroe}(;?ui3#Yg7uJxFqdKAS>OopF7Pq%HSjBP@vIKofH_4Y+I6vg+ zY-tg}3?e(r{iU6gb%fj?UlN^In-ltqPv1CS&eRAwpPMgVJiAhshuVp@KASJ`m+JYl z)C=>aVf#07CBCDcE5l8>@}%YTu)3ol7J(ciOGPcFijw7?9vsYgtya4a|2HR4x8;^6 zPhTR7Ps3oz`6QUwvV*OtT11?wbjC$HgS|l|q7%!Z+9jRq)gd25PE0}A3kX@t2uJu^Yf! z5`PhR75EVN9QZyAOQIchH}D96`zV3?GI1C<37i8i0l(n>z#b<%fCqsm0OVovIp8>O z3b+Vd1^y5}4>5M3qWcW>Qx*?uh-9t&_96dW<~ZVcib|IeKCtUf`nI?%*WhQSa3VI3 RJj%w3y}hYyHkDSCKLO>qqxS#+ literal 0 HcmV?d00001 diff --git a/src/web_accessible_resources/noop.html b/src/web_accessible_resources/noop.html new file mode 100644 index 000000000..8aaae14d1 --- /dev/null +++ b/src/web_accessible_resources/noop.html @@ -0,0 +1,5 @@ + + + + + diff --git a/src/web_accessible_resources/noop.js b/src/web_accessible_resources/noop.js new file mode 100644 index 000000000..b977b08aa --- /dev/null +++ b/src/web_accessible_resources/noop.js @@ -0,0 +1,3 @@ +(function() { + 'use strict'; +})(); diff --git a/src/web_accessible_resources/noop.txt b/src/web_accessible_resources/noop.txt new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/web_accessible_resources/noop.txt @@ -0,0 +1 @@ + diff --git a/src/web_accessible_resources/outbrain-widget.js b/src/web_accessible_resources/outbrain-widget.js new file mode 100644 index 000000000..498f6803e --- /dev/null +++ b/src/web_accessible_resources/outbrain-widget.js @@ -0,0 +1,47 @@ +/******************************************************************************* + + uBlock Origin - a browser extension to block requests. + Copyright (C) 2019-present 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 +*/ + +(function() { + 'use strict'; + const noopfn = function() { + }; + const obr = {}; + const methods = [ + 'callClick', 'callLoadMore', 'callRecs', 'callUserZapping', + 'callWhatIs', 'cancelRecommendation', 'cancelRecs', 'closeCard', + 'closeModal', 'closeTbx', 'errorInjectionHandler', 'getCountOfRecs', + 'getStat', 'imageError', 'manualVideoClicked', 'onOdbReturn', + 'onVideoClick', 'pagerLoad', 'recClicked', 'refreshSpecificWidget', + 'refreshWidget', 'reloadWidget', 'researchWidget', 'returnedError', + 'returnedHtmlData', 'returnedIrdData', 'returnedJsonData', 'scrollLoad', + 'showDescription', 'showRecInIframe', 'userZappingMessage', 'zappingFormAction' + ]; + obr.extern = { + video: { + getVideoRecs: noopfn, + videoClicked: noopfn + } + }; + methods.forEach(function(a) { + obr.extern[a] = noopfn; + }); + window.OBR = window.OBR || obr; +})(); diff --git a/src/web_accessible_resources/popads-dummy.js b/src/web_accessible_resources/popads-dummy.js new file mode 100644 index 000000000..0ca0b1ef1 --- /dev/null +++ b/src/web_accessible_resources/popads-dummy.js @@ -0,0 +1,30 @@ +/******************************************************************************* + + uBlock Origin - a browser extension to block requests. + Copyright (C) 2019-present 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 +*/ + +(function() { + 'use strict'; + delete window.PopAds; + delete window.popns; + Object.defineProperties(window, { + PopAds: { value: {} }, + popns: { value: {} } + }); +})(); diff --git a/src/web_accessible_resources/popads.js b/src/web_accessible_resources/popads.js new file mode 100644 index 000000000..4b6d0b609 --- /dev/null +++ b/src/web_accessible_resources/popads.js @@ -0,0 +1,40 @@ +/******************************************************************************* + + uBlock Origin - a browser extension to block requests. + Copyright (C) 2019-present 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 +*/ + +(function() { + 'use strict'; + const magic = String.fromCharCode(Date.now() % 26 + 97) + + Math.floor(Math.random() * 982451653 + 982451653).toString(36); + const oe = window.onerror; + window.onerror = function(msg, src, line, col, error) { + if ( typeof msg === 'string' && msg.indexOf(magic) !== -1 ) { return true; } + if ( oe instanceof Function ) { + return oe(msg, src, line, col, error); + } + }.bind(); + const throwMagic = function() { throw magic; }; + delete window.PopAds; + delete window.popns; + Object.defineProperties(window, { + PopAds: { set: throwMagic }, + popns: { set: throwMagic } + }); +})(); diff --git a/src/web_accessible_resources/scorecardresearch_beacon.js b/src/web_accessible_resources/scorecardresearch_beacon.js new file mode 100644 index 000000000..5ca7203af --- /dev/null +++ b/src/web_accessible_resources/scorecardresearch_beacon.js @@ -0,0 +1,31 @@ +/******************************************************************************* + + uBlock Origin - a browser extension to block requests. + Copyright (C) 2019-present 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 +*/ + +(function() { + 'use strict'; + window.COMSCORE = { + purge: function() { + window._comscore = []; + }, + beacon: function() { + } + }; +})(); diff --git a/src/web_accessible_resources/set-constant.js b/src/web_accessible_resources/set-constant.js new file mode 100644 index 000000000..f7d4114fa --- /dev/null +++ b/src/web_accessible_resources/set-constant.js @@ -0,0 +1,99 @@ +/******************************************************************************* + + uBlock Origin - a browser extension to block requests. + Copyright (C) 2019-present 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 +*/ + +(function() { + 'use strict'; + const thisScript = document.currentScript; + let cValue = '{{2}}'; + if ( cValue === 'undefined' ) { + cValue = undefined; + } else if ( cValue === 'false' ) { + cValue = false; + } else if ( cValue === 'true' ) { + cValue = true; + } else if ( cValue === 'null' ) { + cValue = null; + } else if ( cValue === 'noopFunc' ) { + cValue = function(){}; + } else if ( cValue === 'trueFunc' ) { + cValue = function(){ return true; }; + } else if ( cValue === 'falseFunc' ) { + cValue = function(){ return false; }; + } else if ( /^\d+$/.test(cValue) ) { + cValue = parseFloat(cValue); + if ( isNaN(cValue) ) { return; } + if ( Math.abs(cValue) > 0x7FFF ) { return; } + } else if ( cValue === "''" ) { + cValue = ''; + } else { + return; + } + let aborted = false; + const mustAbort = function(v) { + if ( aborted ) { return true; } + aborted = v !== undefined && cValue !== undefined && typeof v !== typeof cValue; + return aborted; + }; + const makeProxy = function(owner, chain) { + const pos = chain.indexOf('.'); + if ( pos === -1 ) { + const original = owner[chain]; + if ( mustAbort(original) ) { return; } + const desc = Object.getOwnPropertyDescriptor(owner, chain); + if ( desc === undefined || desc.get === undefined ) { + Object.defineProperty(owner, chain, { + get: function() { + return document.currentScript === thisScript + ? original + : cValue; + }, + set: function(a) { + if ( mustAbort(a) ) { + cValue = a; + } + } + }); + } + return; + } + const prop = chain.slice(0, pos); + let v = owner[prop]; + chain = chain.slice(pos + 1); + if ( v !== undefined ) { + makeProxy(v, chain); + return; + } + const desc = Object.getOwnPropertyDescriptor(owner, prop); + if ( desc && desc.set !== undefined ) { return; } + Object.defineProperty(owner, prop, { + get: function() { + return v; + }, + set: function(a) { + v = a; + if ( a instanceof Object ) { + makeProxy(a, chain); + } + } + }); + }; + makeProxy(window, '{{1}}'); +})(); diff --git a/src/web_accessible_resources/setTimeout-defuser.js b/src/web_accessible_resources/setTimeout-defuser.js new file mode 100644 index 000000000..8bc08c1e4 --- /dev/null +++ b/src/web_accessible_resources/setTimeout-defuser.js @@ -0,0 +1,44 @@ +/******************************************************************************* + + uBlock Origin - a browser extension to block requests. + Copyright (C) 2019-present 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 +*/ + +(function() { + 'use strict'; + let needle = '{{1}}'; + const delay = parseInt('{{2}}', 10); + if ( needle === '' || needle === '{{1}}' ) { + needle = '.?'; + } else if ( needle.startsWith('/') && needle.endsWith('/') ) { + needle = needle.slice(1,-1); + } else { + needle = needle.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + } + needle = new RegExp(needle); + window.setTimeout = new Proxy(window.setTimeout, { + apply: function(target, thisArg, args) { + const a = args[0]; + const b = args[1]; + if ( (isNaN(delay) || b === delay) && needle.test(a.toString()) ) { + args[0] = function(){}; + } + return target.apply(thisArg, args); + } + }); +})(); diff --git a/src/web_accessible_resources/to-import.txt b/src/web_accessible_resources/to-import.txt deleted file mode 100644 index 4096bd7bb..000000000 --- a/src/web_accessible_resources/to-import.txt +++ /dev/null @@ -1,57 +0,0 @@ -# This is a list of resources (by token) which will be converted to -# "web accessible resources", such that uBO will be able to redirect -# to these through moz-extension: or chrome-extension: URLs. -# -# This addresses: -# - https://github.com/gorhill/uBlock/issues/3474 -# - https://github.com/gorhill/uBlock/issues/2823 -# -# uBO attaches a "secret" token internally when redirecting to any -# "web accessible resource", such that it is not possible for a web -# page to use one of these "web accessible resource" to directly -# detect the presence of uBO. -# -# To ensure valid filename characters on any platform OS, the filenames are -# constructed using the md5 hash of the respective tokens. -# -# In case uBO redirects to a resource which has not been converted into -# a "web accessible resource", the redirection code will fall back to -# using a data: URI. -# -# The list below was gathered manually from scanning the use of the -# "redirect=" option in uBO's own filter lists. Eventually a script could -# be written to generate the list below. - -1x1-transparent.gif -2x2-transparent.png -32x32-transparent.png -3x2-transparent.png -addthis.com/addthis_widget.js -amazon-adsystem.com/aax2/amzn_ads.js -ampproject.org/v0.js -antiAdBlock.js -d3pkae9owd2lcf.cloudfront.net/mb105.js -disqus.com/embed.js -disqus.com/forums/*/embed.js -doubleclick.net/instream/ad_status.js -fuckadblock.js-3.2.0 -google-analytics.com/analytics.js -google-analytics.com/cx/api.js -google-analytics.com/ga.js -google-analytics.com/inpage_linkid.js -googlesyndication.com/adsbygoogle.js -googletagmanager.com/gtm.js -googletagservices.com/gpt.js -hd-main.js -ligatus.com/*/angular-tag.js -noopframe -noopjs -noopmp3-0.1s -noopmp4-1s -nooptext -popads-dummy.js -popads.net.js -scorecardresearch.com/beacon.js -silent-noeval.js -static.chartbeat.com/chartbeat.js -widgets.outbrain.com/outbrain.js diff --git a/src/web_accessible_resources/webrtc-if.js b/src/web_accessible_resources/webrtc-if.js new file mode 100644 index 000000000..dfbb8ab6a --- /dev/null +++ b/src/web_accessible_resources/webrtc-if.js @@ -0,0 +1,87 @@ +/******************************************************************************* + + uBlock Origin - a browser extension to block requests. + Copyright (C) 2019-present 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 +*/ + +(function() { + 'use strict'; + let good = '{{1}}'; + if ( good.startsWith('/') && good.endsWith('/') ) { + good = good.slice(1, -1); + } else { + good = good.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + } + let reGood; + try { + reGood = new RegExp(good); + } catch(ex) { + return; + } + const rtcName = window.RTCPeerConnection + ? 'RTCPeerConnection' + : (window.webkitRTCPeerConnection ? 'webkitRTCPeerConnection' : ''); + if ( rtcName === '' ) { return; } + const log = console.log.bind(console); + const neuteredPeerConnections = new WeakSet(); + const isGoodConfig = function(instance, config) { + if ( neuteredPeerConnections.has(instance) ) { return false; } + if ( config instanceof Object === false ) { return true; } + if ( Array.isArray(config.iceServers) === false ) { return true; } + for ( const server of config.iceServers ) { + const urls = typeof server.urls === 'string' + ? [ server.urls ] + : server.urls; + if ( Array.isArray(urls) ) { + for ( const url of urls ) { + if ( reGood.test(url) ) { return true; } + } + } + if ( typeof server.username === 'string' ) { + if ( reGood.test(server.username) ) { return true; } + } + if ( typeof server.credential === 'string' ) { + if ( reGood.test(server.credential) ) { return true; } + } + } + neuteredPeerConnections.add(instance); + return false; + }; + const peerConnectionCtor = window[rtcName]; + const peerConnectionProto = peerConnectionCtor.prototype; + peerConnectionProto.createDataChannel = + new Proxy(peerConnectionProto.createDataChannel, { + apply: function(target, thisArg, args) { + if ( isGoodConfig(target, args[1]) === false ) { + log(args[1]); + return target.apply(thisArg, args.slice(0, 1)); + } + return target.apply(thisArg, args); + }, + }); + window[rtcName] = + new Proxy(peerConnectionCtor, { + construct: function(target, args) { + if ( isGoodConfig(target, args[0]) === false ) { + log(args[0]); + return new target(); + } + return new target(...args); + } + }); +})(); diff --git a/tools/make-chromium.sh b/tools/make-chromium.sh index d473744fe..3307fbca5 100755 --- a/tools/make-chromium.sh +++ b/tools/make-chromium.sh @@ -3,24 +3,13 @@ # This script assumes a linux environment echo "*** uBlock0.chromium: Creating web store package" -echo "*** uBlock0.chromium: Copying files" DES=dist/build/uBlock0.chromium 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 src/*.html $DES/ -cp platform/chromium/*.js $DES/js/ -cp platform/chromium/*.html $DES/ -cp platform/chromium/*.json $DES/ -cp LICENSE.txt $DES/ +echo "*** uBlock0.chromium: copying common files" +bash ./tools/copy-common-files.sh $DES echo "*** uBlock0.chromium: concatenating content scripts" cat $DES/js/vapi-usercss.js > /tmp/contentscript.js @@ -38,10 +27,6 @@ rm $DES/js/vapi-usercss.pseudo.js # Chrome store-specific cp -R $DES/_locales/nb $DES/_locales/no -echo "*** uBlock0.chromium: Generating web accessible resources..." -cp -R src/web_accessible_resources $DES/ -python3 tools/import-war.py $DES/ - echo "*** uBlock0.chromium: Generating meta..." python tools/make-chromium-meta.py $DES/ diff --git a/tools/make-firefox.sh b/tools/make-firefox.sh index 382398acc..f46ed0ce8 100755 --- a/tools/make-firefox.sh +++ b/tools/make-firefox.sh @@ -3,26 +3,16 @@ # This script assumes a linux environment echo "*** uBlock0.firefox: Creating web store package" -echo "*** uBlock0.firefox: Copying files" BLDIR=dist/build DES="$BLDIR"/uBlock0.firefox rm -rf $DES mkdir -p $DES -bash ./tools/make-assets.sh $DES +echo "*** uBlock0.firefox: copying common files" +bash ./tools/copy-common-files.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 platform/chromium/*.js $DES/js/ -cp platform/chromium/*.html $DES/ -cp platform/chromium/*.json $DES/ -cp LICENSE.txt $DES/ cp platform/firefox/manifest.json $DES/ cp platform/firefox/vapi-usercss.js $DES/js/ @@ -42,10 +32,6 @@ rm $DES/js/vapi-usercss.pseudo.js # Firefox/webext-specific rm $DES/img/icon_128.png -echo "*** uBlock0.firefox: Generating web accessible resources..." -cp -R src/web_accessible_resources $DES/ -python3 tools/import-war.py $DES/ - echo "*** uBlock0.firefox: Generating meta..." python tools/make-firefox-meta.py $DES/ diff --git a/tools/make-opera.sh b/tools/make-opera.sh index 8ef41431e..dcff9fdae 100755 --- a/tools/make-opera.sh +++ b/tools/make-opera.sh @@ -3,24 +3,13 @@ # This script assumes a linux environment echo "*** uBlock0.opera: Creating web store package" -echo "*** uBlock0.opera: Copying files" DES=dist/build/uBlock0.opera 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 src/*.html $DES/ -cp platform/chromium/*.js $DES/js/ -cp platform/chromium/*.html $DES/ -cp platform/chromium/*.json $DES/ -cp LICENSE.txt $DES/ +echo "*** uBlock0.opera: copying common files" +bash ./tools/copy-common-files.sh $DES echo "*** uBlock0.opera: concatenating content scripts" cat $DES/js/vapi-usercss.js > /tmp/contentscript.js @@ -57,10 +46,6 @@ rm $DES/lib/lz4/*.wat rm $DES/lib/publicsuffixlist/wasm/*.wasm rm $DES/lib/publicsuffixlist/wasm/*.wat -echo "*** uBlock0.opera: Generating web accessible resources..." -cp -R src/web_accessible_resources $DES/ -python3 tools/import-war.py $DES/ - echo "*** uBlock0.opera: Generating meta..." python tools/make-opera-meta.py $DES/ diff --git a/tools/make-thunderbird.sh b/tools/make-thunderbird.sh index 1df213eb6..c99d80606 100755 --- a/tools/make-thunderbird.sh +++ b/tools/make-thunderbird.sh @@ -3,26 +3,16 @@ # This script assumes a linux environment echo "*** uBlock0.thunderbird: Creating web store package" -echo "*** uBlock0.thunderbird: Copying files" BLDIR=dist/build DES="$BLDIR"/uBlock0.thunderbird rm -rf $DES mkdir -p $DES -bash ./tools/make-assets.sh $DES +echo "*** uBlock0.thunderbird: copying common files" +bash ./tools/copy-common-files.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 platform/chromium/*.js $DES/js/ -cp platform/chromium/*.html $DES/ -cp platform/chromium/*.json $DES/ -cp LICENSE.txt $DES/ cp platform/thunderbird/manifest.json $DES/ cp platform/firefox/vapi-webrequest.js $DES/js/ @@ -42,10 +32,6 @@ rm $DES/js/vapi-usercss.pseudo.js # Firefox/webext-specific rm $DES/img/icon_128.png -echo "*** uBlock0.thunderbird: Generating web accessible resources..." -cp -R src/web_accessible_resources $DES/ -python3 tools/import-war.py $DES/ - echo "*** uBlock0.thunderbird: Generating meta..." python tools/make-firefox-meta.py $DES/ diff --git a/tools/make-webext.sh b/tools/make-webext.sh index fc1a80640..601afc4a8 100755 --- a/tools/make-webext.sh +++ b/tools/make-webext.sh @@ -6,25 +6,15 @@ set -e echo "*** uBlock0.webext: Creating web store package" -echo "*** uBlock0.webext: Copying files" DES=dist/build/uBlock0.webext rm -rf $DES mkdir -p $DES -bash ./tools/make-assets.sh $DES +echo "*** uBlock0.webext: copying common files" +bash ./tools/copy-common-files.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 platform/chromium/*.js $DES/js/ -cp platform/chromium/*.html $DES/ -cp platform/chromium/*.json $DES/ -cp LICENSE.txt $DES/ cp platform/webext/manifest.json $DES/ cp platform/webext/vapi-usercss.js $DES/js/ @@ -49,10 +39,6 @@ rm $DES/js/vapi-usercss.js rm $DES/js/vapi-usercss.real.js rm $DES/js/vapi-usercss.pseudo.js -echo "*** uBlock0.webext: Generating web accessible resources..." -cp -R src/web_accessible_resources $DES/ -python3 tools/import-war.py $DES/ - echo "*** uBlock0.webext: Generating meta..." python3 tools/make-webext-meta.py $DES/