diff --git a/.jshintrc b/.jshintrc index 5d43f6df9..d2fe2c38f 100644 --- a/.jshintrc +++ b/.jshintrc @@ -6,12 +6,8 @@ "globals": { "browser": false, // global variable in Firefox, Edge "chrome": false, // global variable in Chromium, Chrome, Opera - "log": false, - "safari": false, "self": false, "vAPI": false, - "webext": false, - "µBlock": false, "URLSearchParams": false, "WebAssembly": false }, diff --git a/platform/chromium/webext.js b/platform/chromium/webext.js index 1acb1ee56..c96c3de82 100644 --- a/platform/chromium/webext.js +++ b/platform/chromium/webext.js @@ -24,9 +24,6 @@ // `webext` is a promisified api of `chrome`. Entries are added as // the promisification of uBO progress. -const webext = (( ) => { // jshint ignore:line -// >>>>> start of private scope - const promisifyNoFail = function(thisArg, fnName, outFn = r => r) { const fn = thisArg[fnName]; return function() { @@ -164,7 +161,4 @@ if ( chrome.tabs.removeCSS instanceof Function ) { webext.tabs.removeCSS = promisifyNoFail(chrome.tabs, 'removeCSS'); } -return webext; - -// <<<<< end of private scope -})(); +export default webext; diff --git a/platform/common/vapi-background.js b/platform/common/vapi-background.js index 8558a1ea9..b9b425944 100644 --- a/platform/common/vapi-background.js +++ b/platform/common/vapi-background.js @@ -26,6 +26,7 @@ /******************************************************************************/ +import webext from './webext.js'; import { ubolog } from './console.js'; /******************************************************************************/ @@ -1252,50 +1253,6 @@ vAPI.Net = class { canSuspend() { return false; } - async benchmark() { - if ( typeof µBlock !== 'object' ) { return; } - const requests = await µBlock.loadBenchmarkDataset(); - if ( Array.isArray(requests) === false || requests.length === 0 ) { - console.info('No requests found to benchmark'); - return; - } - const mappedTypes = new Map([ - [ 'document', 'main_frame' ], - [ 'subdocument', 'sub_frame' ], - ]); - console.info('vAPI.net.onBeforeSuspendableRequest()...'); - const t0 = self.performance.now(); - const promises = []; - const details = { - documentUrl: '', - tabId: -1, - parentFrameId: -1, - frameId: 0, - type: '', - url: '', - }; - for ( const request of requests ) { - details.documentUrl = request.frameUrl; - details.tabId = -1; - details.parentFrameId = -1; - details.frameId = 0; - details.type = mappedTypes.get(request.cpt) || request.cpt; - details.url = request.url; - if ( details.type === 'main_frame' ) { continue; } - promises.push(this.onBeforeSuspendableRequest(details)); - } - return Promise.all(promises).then(results => { - let blockCount = 0; - for ( const r of results ) { - if ( r !== undefined ) { blockCount += 1; } - } - const t1 = self.performance.now(); - const dur = t1 - t0; - console.info(`Evaluated ${requests.length} requests in ${dur.toFixed(0)} ms`); - console.info(`\tBlocked ${blockCount} requests`); - console.info(`\tAverage: ${(dur / requests.length).toFixed(3)} ms per request`); - }); - } }; /******************************************************************************/ diff --git a/platform/firefox/webext.js b/platform/firefox/webext.js index 4729e7c17..761da61c4 100644 --- a/platform/firefox/webext.js +++ b/platform/firefox/webext.js @@ -21,4 +21,4 @@ 'use strict'; -const webext = browser; // jshint ignore:line +export default browser; diff --git a/src/background.html b/src/background.html index 9f085da94..da1c03b01 100644 --- a/src/background.html +++ b/src/background.html @@ -6,17 +6,7 @@
- - - - - - - - - -