mirror of
https://github.com/gorhill/uBlock.git
synced 2025-01-31 12:11:36 +01:00
Better integrate latest eslint version
This commit is contained in:
parent
4b12247da1
commit
f8975e3a6a
@ -1,30 +0,0 @@
|
||||
env:
|
||||
browser: true
|
||||
es2022: true
|
||||
extends: eslint:recommended
|
||||
parserOptions:
|
||||
sourceType: module
|
||||
rules:
|
||||
eqeqeq:
|
||||
- warn
|
||||
- always
|
||||
indent:
|
||||
- error
|
||||
- 4
|
||||
- ignoredNodes:
|
||||
- Program > BlockStatement
|
||||
- Program > ExpressionStatement > CallExpression > ArrowFunctionExpression > BlockStatement
|
||||
- Program > ExpressionStatement > CallExpression > FunctionExpression > BlockStatement
|
||||
- Program > IfStatement > BlockStatement
|
||||
- Program > VariableDeclaration > VariableDeclarator > CallExpression > ArrowFunctionExpression > BlockStatement
|
||||
- CallExpression > MemberExpression
|
||||
- ArrayExpression > *
|
||||
- ObjectExpression > *
|
||||
no-control-regex: off
|
||||
no-empty: off
|
||||
sort-imports: warn
|
||||
strict: warn
|
||||
globals:
|
||||
browser: readonly
|
||||
chrome: readonly
|
||||
vAPI: readonly
|
22
.jshintrc
22
.jshintrc
@ -1,22 +0,0 @@
|
||||
{
|
||||
"browser": true,
|
||||
"devel": true,
|
||||
"eqeqeq": true,
|
||||
"esversion": 11,
|
||||
"globals": {
|
||||
"chrome": false, // global variable in Chromium, Chrome, Opera
|
||||
"globalThis": false,
|
||||
"self": false,
|
||||
"vAPI": false,
|
||||
"URLSearchParams": false,
|
||||
"WebAssembly": false
|
||||
},
|
||||
"laxbreak": true,
|
||||
"newcap": false,
|
||||
"nonew": false,
|
||||
"strict": "global",
|
||||
"sub": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"validthis": true
|
||||
}
|
7
Makefile
7
Makefile
@ -32,11 +32,12 @@ firefox: dist/build/uBlock0.firefox
|
||||
dist/build/uBlock0.npm: tools/make-nodejs.sh $(sources) $(platform) $(assets)
|
||||
tools/make-npm.sh
|
||||
|
||||
# Build the Node.js package.
|
||||
npm: dist/build/uBlock0.npm
|
||||
# Dev tools
|
||||
npm: node_modules/
|
||||
npm install
|
||||
|
||||
lint: npm
|
||||
cd dist/build/uBlock0.npm && npm run lint
|
||||
npm run lint
|
||||
|
||||
test: npm
|
||||
cd dist/build/uBlock0.npm && npm run test
|
||||
|
51
eslint.config.mjs
Normal file
51
eslint.config.mjs
Normal file
@ -0,0 +1,51 @@
|
||||
import js from "@eslint/js";
|
||||
import globals from "globals";
|
||||
import json from "@eslint/json";
|
||||
|
||||
import { includeIgnoreFile } from "@eslint/compat";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const gitignorePath = path.resolve(__dirname, ".gitignore");
|
||||
|
||||
export default [ includeIgnoreFile(gitignorePath), {
|
||||
files: ["**/*.js", "**/*.mjs"],
|
||||
...js.configs.recommended,
|
||||
}, {
|
||||
files: ["**/*.js", "**/*.mjs"],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.browser,
|
||||
browser: "readonly",
|
||||
chrome: "readonly",
|
||||
vAPI: "readonly",
|
||||
},
|
||||
sourceType: "module",
|
||||
},
|
||||
rules: {
|
||||
eqeqeq: ["warn", "always"],
|
||||
indent: ["error", 4, {
|
||||
ignoredNodes: [
|
||||
"Program > BlockStatement",
|
||||
"Program > ExpressionStatement > CallExpression > ArrowFunctionExpression > BlockStatement",
|
||||
"Program > ExpressionStatement > CallExpression > FunctionExpression > BlockStatement",
|
||||
"Program > IfStatement > BlockStatement",
|
||||
"Program > VariableDeclaration > VariableDeclarator > CallExpression > ArrowFunctionExpression > BlockStatement",
|
||||
"CallExpression > MemberExpression",
|
||||
"ArrayExpression > *",
|
||||
"ObjectExpression > *",
|
||||
],
|
||||
}],
|
||||
"no-control-regex": "off",
|
||||
"no-empty": "off",
|
||||
"sort-imports": "error",
|
||||
"strict": "error",
|
||||
},
|
||||
}, {
|
||||
files: ["**/*.json"],
|
||||
ignores: ["package-lock.json"],
|
||||
language: "json/json",
|
||||
...json.configs.recommended,
|
||||
} ];
|
1146
package-lock.json
generated
Normal file
1146
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
32
package.json
Normal file
32
package.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "uBlock",
|
||||
"version": "1.0.0",
|
||||
"description": "npm dev tools",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint ./src/js/*.js ./src/js/**/*.js ./**/*.json ./platform/**/*.js ",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/gorhill/uBlock.git"
|
||||
},
|
||||
"author": "Raymond Hill",
|
||||
"license": "GPLv3",
|
||||
"bugs": {
|
||||
"url": "https://github.com/gorhill/uBlock/issues"
|
||||
},
|
||||
"homepage": "https://github.com/gorhill/uBlock#readme",
|
||||
"engines": {
|
||||
"node": ">=22",
|
||||
"npm": ">=11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.2.4",
|
||||
"@eslint/js": "^9.17.0",
|
||||
"@eslint/json": "^0.9.0",
|
||||
"eslint": "^9.17.0",
|
||||
"eslint-formatter-compact": "^8.40.0",
|
||||
"globals": "^15.14.0"
|
||||
}
|
||||
}
|
@ -1,123 +0,0 @@
|
||||
/*******************************************************************************
|
||||
|
||||
uBlock Origin - a browser extension to block requests.
|
||||
Copyright (C) 2014-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
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import publicSuffixList from './lib/publicsuffixlist/publicsuffixlist.js';
|
||||
import punycode from './lib/punycode.js';
|
||||
|
||||
import staticNetFilteringEngine from './js/static-net-filtering.js';
|
||||
import { FilteringContext } from './js/filtering-context.js';
|
||||
import { LineIterator } from './js/text-utils.js';
|
||||
import * as sfp from './js/static-filtering-parser.js';
|
||||
|
||||
import {
|
||||
CompiledListReader,
|
||||
CompiledListWriter
|
||||
} from './js/static-filtering-io.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
function compileList(rawText, writer) {
|
||||
const lineIter = new LineIterator(rawText);
|
||||
const parser = new sfp.AstFilterParser({
|
||||
interactive: true,
|
||||
maxTokenLength: staticNetFilteringEngine.MAX_TOKEN_LENGTH,
|
||||
});
|
||||
const compiler = staticNetFilteringEngine.createCompiler();
|
||||
|
||||
while ( lineIter.eot() === false ) {
|
||||
let line = lineIter.next();
|
||||
|
||||
while ( line.endsWith(' \\') ) {
|
||||
if ( lineIter.peek(4) !== ' ' ) { break; }
|
||||
line = line.slice(0, -2).trim() + lineIter.next().trim();
|
||||
}
|
||||
parser.parse(line);
|
||||
|
||||
if ( parser.isFilter() === false ) { continue; }
|
||||
if ( parser.isNetworkFilter() === false ) { continue; }
|
||||
if ( compiler.compile(parser, writer) ) { continue; }
|
||||
if ( compiler.error !== undefined ) {
|
||||
console.info(JSON.stringify({
|
||||
realm: 'message',
|
||||
type: 'error',
|
||||
text: compiler.error
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
function applyList(name, raw) {
|
||||
const writer = new CompiledListWriter();
|
||||
writer.properties.set('name', name);
|
||||
const compiled = compileList(raw, writer);
|
||||
const reader = new CompiledListReader(compiled);
|
||||
staticNetFilteringEngine.fromCompiled(reader);
|
||||
}
|
||||
|
||||
function enableWASM(path) {
|
||||
return Promise.all([
|
||||
publicSuffixList.enableWASM(`${path}/lib/publicsuffixlist`),
|
||||
staticNetFilteringEngine.enableWASM(`${path}/js`),
|
||||
]);
|
||||
}
|
||||
|
||||
function pslInit(raw) {
|
||||
if ( typeof raw !== 'string' || raw.trim() === '' ) {
|
||||
console.info('Unable to populate public suffix list');
|
||||
return;
|
||||
}
|
||||
publicSuffixList.parse(raw, punycode.toASCII);
|
||||
console.info('Public suffix list populated');
|
||||
}
|
||||
|
||||
function restart(lists) {
|
||||
// Remove all filters
|
||||
reset();
|
||||
|
||||
if ( Array.isArray(lists) && lists.length !== 0 ) {
|
||||
// Populate filtering engine with filter lists
|
||||
for ( const { name, raw } of lists ) {
|
||||
applyList(name, raw);
|
||||
}
|
||||
// Commit changes
|
||||
staticNetFilteringEngine.freeze();
|
||||
staticNetFilteringEngine.optimize();
|
||||
}
|
||||
|
||||
return staticNetFilteringEngine;
|
||||
}
|
||||
|
||||
function reset() {
|
||||
staticNetFilteringEngine.reset();
|
||||
}
|
||||
|
||||
export {
|
||||
FilteringContext,
|
||||
enableWASM,
|
||||
pslInit,
|
||||
restart,
|
||||
};
|
@ -1,71 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>uBO Static Network Filtering Engine</title>
|
||||
</head>
|
||||
<body>
|
||||
<script type="module">
|
||||
import {
|
||||
FilteringContext,
|
||||
enableWASM,
|
||||
pslInit,
|
||||
restart,
|
||||
} from './main.js';
|
||||
|
||||
(async ( ) => {
|
||||
await enableWASM('.');
|
||||
|
||||
await fetch('./data/effective_tld_names.dat').then(response => {
|
||||
return response.text();
|
||||
}).then(pslRaw => {
|
||||
pslInit(pslRaw);
|
||||
});
|
||||
|
||||
const snfe = await Promise.all([
|
||||
fetch('./data/easylist.txt').then(response => {
|
||||
return response.text();
|
||||
}),
|
||||
fetch('./data/easyprivacy.txt').then(response => {
|
||||
return response.text();
|
||||
}),
|
||||
]).then(rawLists => {
|
||||
return restart([
|
||||
{ name: 'easylist', raw: rawLists[0] },
|
||||
{ name: 'easyprivacy', raw: rawLists[1] },
|
||||
]);
|
||||
});
|
||||
|
||||
// Reuse filtering context: it's what uBO does
|
||||
const fctxt = new FilteringContext();
|
||||
|
||||
// Tests
|
||||
// Not blocked
|
||||
fctxt.setDocOriginFromURL('https://www.bloomberg.com/');
|
||||
fctxt.setURL('https://www.bloomberg.com/tophat/assets/v2.6.1/that.css');
|
||||
fctxt.setType('stylesheet');
|
||||
if ( snfe.matchRequest(fctxt) !== 0 ) {
|
||||
console.log(snfe.toLogData());
|
||||
}
|
||||
|
||||
// Blocked
|
||||
fctxt.setDocOriginFromURL('https://www.bloomberg.com/');
|
||||
fctxt.setURL('https://securepubads.g.doubleclick.net/tag/js/gpt.js');
|
||||
fctxt.setType('script');
|
||||
if ( snfe.matchRequest(fctxt) !== 0 ) {
|
||||
console.log(snfe.toLogData());
|
||||
}
|
||||
|
||||
// Unblocked
|
||||
fctxt.setDocOriginFromURL('https://www.bloomberg.com/');
|
||||
fctxt.setURL('https://sourcepointcmp.bloomberg.com/ccpa.js');
|
||||
fctxt.setType('script');
|
||||
if ( snfe.matchRequest(fctxt) !== 0 ) {
|
||||
console.log(snfe.toLogData());
|
||||
}
|
||||
|
||||
restart();
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -3,7 +3,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<script async src="js/is-webrtc-supported.js"></script>
|
||||
<script async src="js/is-webrtc-supported.js" type="module"></script>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
|
@ -30,11 +30,9 @@
|
||||
// collected.
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
var pc = null;
|
||||
let pc = null;
|
||||
try {
|
||||
var PC = self.RTCPeerConnection || self.webkitRTCPeerConnection;
|
||||
const PC = self.RTCPeerConnection || self.webkitRTCPeerConnection;
|
||||
if ( PC ) {
|
||||
pc = new PC(null);
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ vAPI.scriptletsInjector = (( ) => {
|
||||
script.appendChild(doc.createTextNode(details.scriptlets));
|
||||
(doc.head || doc.documentElement).appendChild(script);
|
||||
self.uBO_scriptletsInjected = details.filters;
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
}
|
||||
if ( script ) {
|
||||
script.remove();
|
||||
|
@ -320,7 +320,7 @@ vAPI.Tabs = class {
|
||||
try {
|
||||
result = await webext.tabs.executeScript(...args);
|
||||
}
|
||||
catch(reason) {
|
||||
catch {
|
||||
}
|
||||
return Array.isArray(result) ? result : [];
|
||||
}
|
||||
@ -334,7 +334,7 @@ vAPI.Tabs = class {
|
||||
try {
|
||||
tab = await webext.tabs.get(tabId);
|
||||
}
|
||||
catch(reason) {
|
||||
catch {
|
||||
}
|
||||
return tab instanceof Object ? tab : null;
|
||||
}
|
||||
@ -351,7 +351,7 @@ vAPI.Tabs = class {
|
||||
try {
|
||||
await webext.tabs.insertCSS(...arguments);
|
||||
}
|
||||
catch(reason) {
|
||||
catch {
|
||||
}
|
||||
}
|
||||
|
||||
@ -360,7 +360,7 @@ vAPI.Tabs = class {
|
||||
try {
|
||||
tabs = await webext.tabs.query(queryInfo);
|
||||
}
|
||||
catch(reason) {
|
||||
catch {
|
||||
}
|
||||
return Array.isArray(tabs) ? tabs : [];
|
||||
}
|
||||
@ -372,7 +372,7 @@ vAPI.Tabs = class {
|
||||
try {
|
||||
await webext.tabs.removeCSS(...arguments);
|
||||
}
|
||||
catch(reason) {
|
||||
catch {
|
||||
}
|
||||
}
|
||||
|
||||
@ -530,7 +530,7 @@ vAPI.Tabs = class {
|
||||
try {
|
||||
tab = await webext.tabs.update(...arguments);
|
||||
}
|
||||
catch (reason) {
|
||||
catch {
|
||||
}
|
||||
return tab instanceof Object ? tab : null;
|
||||
}
|
||||
@ -556,7 +556,7 @@ vAPI.Tabs = class {
|
||||
try {
|
||||
await webext.tabs.remove(tabId);
|
||||
}
|
||||
catch (reason) {
|
||||
catch {
|
||||
}
|
||||
}
|
||||
|
||||
@ -569,7 +569,7 @@ vAPI.Tabs = class {
|
||||
{ bypassCache: bypassCache === true }
|
||||
);
|
||||
}
|
||||
catch (reason) {
|
||||
catch {
|
||||
}
|
||||
}
|
||||
|
||||
@ -668,7 +668,7 @@ if ( webext.windows instanceof Object ) {
|
||||
try {
|
||||
win = await webext.windows.get(...arguments);
|
||||
}
|
||||
catch (reason) {
|
||||
catch {
|
||||
}
|
||||
return win instanceof Object ? win : null;
|
||||
},
|
||||
@ -677,7 +677,7 @@ if ( webext.windows instanceof Object ) {
|
||||
try {
|
||||
win = await webext.windows.create(...arguments);
|
||||
}
|
||||
catch (reason) {
|
||||
catch {
|
||||
}
|
||||
return win instanceof Object ? win : null;
|
||||
},
|
||||
@ -686,7 +686,7 @@ if ( webext.windows instanceof Object ) {
|
||||
try {
|
||||
win = await webext.windows.update(...arguments);
|
||||
}
|
||||
catch (reason) {
|
||||
catch {
|
||||
}
|
||||
return win instanceof Object ? win : null;
|
||||
},
|
||||
@ -702,7 +702,7 @@ if ( webext.browserAction instanceof Object ) {
|
||||
try {
|
||||
await webext.browserAction.setTitle(...arguments);
|
||||
}
|
||||
catch (reason) {
|
||||
catch {
|
||||
}
|
||||
},
|
||||
};
|
||||
@ -712,28 +712,28 @@ if ( webext.browserAction instanceof Object ) {
|
||||
try {
|
||||
await webext.browserAction.setBadgeTextColor(...arguments);
|
||||
}
|
||||
catch (reason) {
|
||||
catch {
|
||||
}
|
||||
};
|
||||
vAPI.browserAction.setBadgeBackgroundColor = async function() {
|
||||
try {
|
||||
await webext.browserAction.setBadgeBackgroundColor(...arguments);
|
||||
}
|
||||
catch (reason) {
|
||||
catch {
|
||||
}
|
||||
};
|
||||
vAPI.browserAction.setBadgeText = async function() {
|
||||
try {
|
||||
await webext.browserAction.setBadgeText(...arguments);
|
||||
}
|
||||
catch (reason) {
|
||||
catch {
|
||||
}
|
||||
};
|
||||
vAPI.browserAction.setIcon = async function() {
|
||||
try {
|
||||
await webext.browserAction.setIcon(...arguments);
|
||||
}
|
||||
catch (reason) {
|
||||
catch {
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -807,7 +807,7 @@ if ( webext.browserAction instanceof Object ) {
|
||||
let data;
|
||||
try {
|
||||
data = ctx.getImageData(0, 0, w, h);
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
return data;
|
||||
};
|
||||
@ -1084,7 +1084,7 @@ vAPI.messaging = {
|
||||
msgId: this.msgId,
|
||||
msg: response !== undefined ? response : null,
|
||||
});
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
this.messaging.onPortDisconnect(this.port);
|
||||
}
|
||||
// Store for reuse
|
||||
@ -1473,7 +1473,7 @@ vAPI.adminStorage = (( ) => {
|
||||
let store;
|
||||
try {
|
||||
store = await webext.storage.managed.get();
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
vAPI.storage.set({ cachedManagedStorage: store || {} });
|
||||
};
|
||||
@ -1488,7 +1488,7 @@ vAPI.adminStorage = (( ) => {
|
||||
} else {
|
||||
bin = bin.cachedManagedStorage;
|
||||
}
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
bin = {};
|
||||
}
|
||||
cacheManagedStorage();
|
||||
@ -1688,7 +1688,7 @@ vAPI.cloud = (( ) => {
|
||||
// operation to fail.
|
||||
try {
|
||||
await deleteChunks(datakey, chunkCount + 1);
|
||||
} catch (reason) {
|
||||
} catch {
|
||||
}
|
||||
|
||||
// Push the data to browser-provided cloud storage.
|
||||
@ -1742,7 +1742,7 @@ vAPI.cloud = (( ) => {
|
||||
if ( typeof entry === 'string' ) {
|
||||
entry = JSON.parse(entry);
|
||||
}
|
||||
} catch(_) {
|
||||
} catch {
|
||||
}
|
||||
return entry;
|
||||
};
|
||||
@ -1763,7 +1763,7 @@ vAPI.cloud = (( ) => {
|
||||
webext.storage.sync.getBytesInUse(keys),
|
||||
webext.storage.sync.getBytesInUse(null),
|
||||
]);
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
if ( Array.isArray(results) === false ) { return; }
|
||||
return { used: results[0], total: results[1], max: QUOTA_BYTES };
|
||||
|
@ -165,7 +165,7 @@ vAPI.messaging = {
|
||||
}
|
||||
try {
|
||||
this.port = browser.runtime.connect({name: vAPI.sessionId}) || null;
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
this.port = null;
|
||||
}
|
||||
// Not having a valid port at this point means the main process is
|
||||
|
@ -19,22 +19,12 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* eslint-disable-next-line no-redeclare */
|
||||
/* globals process */
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import { strict as assert } from 'assert';
|
||||
import { StaticNetFilteringEngine, enableWASM } from './index.js';
|
||||
import { mkdir, readFile, writeFile } from 'fs/promises';
|
||||
import { createRequire } from 'module';
|
||||
import { readFile, writeFile, mkdir } from 'fs/promises';
|
||||
import { dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
import { enableWASM, StaticNetFilteringEngine } from './index.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -373,7 +373,7 @@ vAPI.scriptletsInjector = (( ) => {
|
||||
script = doc.createElement('script');
|
||||
script.appendChild(doc.createTextNode(code));
|
||||
(doc.head || doc.documentElement).appendChild(script);
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
}
|
||||
if ( script ) {
|
||||
script.remove();
|
||||
@ -400,7 +400,7 @@ vAPI.scriptletsInjector = (( ) => {
|
||||
script.src = url;
|
||||
(doc.head || doc.documentElement || doc).append(script);
|
||||
self.uBO_scriptletsInjected = details.filters;
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
}
|
||||
if ( url ) {
|
||||
if ( script ) { script.remove(); }
|
||||
|
@ -19,6 +19,4 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
export default browser;
|
||||
|
@ -125,7 +125,7 @@ const fetchText = (url, cacheDir) => {
|
||||
const content = data.join('');
|
||||
try {
|
||||
writeFile(`${cacheDir}/${fname}`, content);
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
}
|
||||
resolve({ url, content });
|
||||
});
|
||||
|
@ -19,10 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
export function safeReplace(text, pattern, replacement, count = 1) {
|
||||
const rePattern = typeof pattern === 'string'
|
||||
? new RegExp(pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
|
||||
|
@ -19,12 +19,7 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import fs from 'fs';
|
||||
|
||||
import { pslInit } from './index.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -19,6 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* globals process */
|
||||
|
||||
import * as s14e from './js/s14e-serializer.js';
|
||||
import * as sfp from './js/static-filtering-parser.js';
|
||||
|
||||
@ -188,7 +190,7 @@ async function useLists(lists, options = {}) {
|
||||
|
||||
useLists.promise = Promise.all(promises);
|
||||
await useLists.promise;
|
||||
useLists.promise = null; // eslint-disable-line require-atomic-updates
|
||||
useLists.promise = null;
|
||||
|
||||
// Commit changes
|
||||
snfe.freeze();
|
||||
@ -283,7 +285,7 @@ class StaticNetFilteringEngine {
|
||||
// module.exports. Once all included files are written like ES modules, using
|
||||
// export statements, this should no longer be necessary.
|
||||
if ( typeof module !== 'undefined' && typeof exports !== 'undefined' ) {
|
||||
module.exports = exports;
|
||||
module.exports = exports; // eslint-disable-line no-undef
|
||||
}
|
||||
|
||||
export {
|
||||
|
@ -1,38 +0,0 @@
|
||||
{
|
||||
"root": true,
|
||||
"env": {
|
||||
"es2021": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 12,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"eqeqeq": [ "warn", "always" ],
|
||||
"indent": [
|
||||
"warn",
|
||||
4,
|
||||
{
|
||||
"ArrayExpression": "first",
|
||||
"CallExpression": { "arguments": "first" },
|
||||
"MemberExpression": "off",
|
||||
"ObjectExpression": "off",
|
||||
"ignoreComments": true,
|
||||
"ignoredNodes": [
|
||||
"AssignmentExpression:has(Literal)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"getter-return": "off",
|
||||
"no-control-regex": "off",
|
||||
"no-empty": [ "error", { "allowEmptyCatch": true } ],
|
||||
"no-promise-executor-return": [ "error" ],
|
||||
"no-template-curly-in-string": [ "error" ],
|
||||
"no-unreachable-loop": [ "error" ],
|
||||
"no-useless-backreference": [ "error" ],
|
||||
"no-useless-escape": "off",
|
||||
"require-atomic-updates": [ "warn" ]
|
||||
}
|
||||
}
|
@ -31,8 +31,8 @@
|
||||
*
|
||||
* */
|
||||
|
||||
import fs from 'fs/promises';
|
||||
import { StaticNetFilteringEngine } from '@gorhill/ubo-core';
|
||||
import fs from 'fs/promises';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"build": "node build.js",
|
||||
"lint": "eslint js/ *.js tests/*.js",
|
||||
"test": "c8 --include=index.js --include=js/**/*.js node test.js --mocha",
|
||||
"test-full-battery": "c8 --include=index.js --include=js/**/*.js node test.js --mocha --full-battery",
|
||||
"check-leaks": "mocha --check-leaks tests/leaks.js"
|
||||
@ -36,7 +35,6 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"c8": "^7.12.0",
|
||||
"eslint": "^8.29.0",
|
||||
"esm-world": "0.1.3",
|
||||
"mocha": "^10.2.0",
|
||||
"scaling-palm-tree": "github:mjethani/scaling-palm-tree#15cf1ab37e038771e1ff8005edc46d95f176739f"
|
||||
|
@ -19,15 +19,10 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* eslint-disable-next-line no-redeclare */
|
||||
/* globals process */
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import { spawn } from "child_process";
|
||||
import { promisify } from 'util';
|
||||
import { spawn } from "child_process";
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { dom } from './dom.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -21,8 +21,6 @@
|
||||
|
||||
/* global CodeMirror, uBlockDashboard */
|
||||
|
||||
'use strict';
|
||||
|
||||
import { dom, qs$ } from './dom.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -21,12 +21,8 @@
|
||||
|
||||
/* global CodeMirror, uBlockDashboard */
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import { dom, qs$ } from './dom.js';
|
||||
import './codemirror/ubo-static-filtering.js';
|
||||
import { dom, qs$ } from './dom.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -319,7 +319,7 @@ assets.fetch = function(url, options = {}) {
|
||||
xhr.responseType = options.responseType || 'text';
|
||||
xhr.send();
|
||||
timeoutTimer.on({ sec: timeoutAfter });
|
||||
} catch (e) {
|
||||
} catch {
|
||||
onErrorEvent.call(xhr);
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ assets.fetchFilterList = async function(mainlistURL) {
|
||||
const toParsedURL = url => {
|
||||
try {
|
||||
return new URL(url.trim());
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
}
|
||||
};
|
||||
|
||||
@ -622,7 +622,7 @@ function updateAssetSourceRegistry(json, silent = false) {
|
||||
Array.from(Object.entries(newDict))
|
||||
.filter(a => a[1].content === 'filters' && a[1].off === undefined)
|
||||
.map(a => a[0]);
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
}
|
||||
if ( newDict instanceof Object === false ) { return; }
|
||||
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// Custom base64 codecs. These codecs are meant to encode/decode typed arrays
|
||||
|
@ -89,7 +89,7 @@ const loadBenchmarkDataset = (( ) => {
|
||||
if ( details.content.startsWith('[') ) {
|
||||
try {
|
||||
requests = JSON.parse(details.content);
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
} else {
|
||||
const lineIter = new LineIterator(details.content);
|
||||
@ -99,7 +99,7 @@ const loadBenchmarkDataset = (( ) => {
|
||||
if ( line === '' ) { continue; }
|
||||
try {
|
||||
parsed.push(JSON.parse(line));
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
parsed.length = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -480,7 +480,7 @@ const idbStorage = (( ) => {
|
||||
try {
|
||||
const db = ev.target.result;
|
||||
db.createObjectStore(STORAGE_NAME, { keyPath: 'key' });
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
req.onerror();
|
||||
}
|
||||
};
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,12 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global faIconsInit */
|
||||
|
||||
'use strict';
|
||||
|
||||
import { i18n, i18n$ } from './i18n.js';
|
||||
import { dom, qs$ } from './dom.js';
|
||||
import { i18n, i18n$ } from './i18n.js';
|
||||
import { faIconsInit } from './fa-icons.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -21,10 +21,6 @@
|
||||
|
||||
/* globals CodeMirror, uBlockDashboard, beautifier */
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import { dom, qs$ } from './dom.js';
|
||||
import { getActualTheme } from './theme.js';
|
||||
|
||||
@ -117,25 +113,25 @@ async function fetchResource(url) {
|
||||
}
|
||||
};
|
||||
switch ( mime ) {
|
||||
case 'text/css':
|
||||
text = beautifier.css(text, beautifierOptions);
|
||||
break;
|
||||
case 'text/html':
|
||||
case 'application/xhtml+xml':
|
||||
case 'application/xml':
|
||||
case 'image/svg+xml':
|
||||
text = beautifier.html(text, beautifierOptions);
|
||||
break;
|
||||
case 'text/javascript':
|
||||
case 'application/javascript':
|
||||
case 'application/x-javascript':
|
||||
text = beautifier.js(text, beautifierOptions);
|
||||
break;
|
||||
case 'application/json':
|
||||
text = beautifier.js(text, beautifierOptions);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 'text/css':
|
||||
text = beautifier.css(text, beautifierOptions);
|
||||
break;
|
||||
case 'text/html':
|
||||
case 'application/xhtml+xml':
|
||||
case 'application/xml':
|
||||
case 'image/svg+xml':
|
||||
text = beautifier.html(text, beautifierOptions);
|
||||
break;
|
||||
case 'text/javascript':
|
||||
case 'application/javascript':
|
||||
case 'application/x-javascript':
|
||||
text = beautifier.js(text, beautifierOptions);
|
||||
break;
|
||||
case 'application/json':
|
||||
text = beautifier.js(text, beautifierOptions);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return { mime, text };
|
||||
}
|
||||
@ -182,7 +178,7 @@ async function setURL(resourceURL) {
|
||||
const url = new URL(resourceURL, currentURL || undefined);
|
||||
url.hash = '';
|
||||
afterURL = url.href;
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
if ( afterURL === undefined ) { return; }
|
||||
} else {
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
(( ) => {
|
||||
@ -43,7 +41,7 @@ if (
|
||||
let reSearch;
|
||||
try {
|
||||
reSearch = new RegExp(details.pattern, details.flags);
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -88,11 +86,14 @@ if (
|
||||
content = msg.content;
|
||||
break;
|
||||
|
||||
case 'doSearch':
|
||||
case 'doSearch': {
|
||||
const response = doSearch(msg);
|
||||
self.postMessage({ id: msg.id, response });
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
return;
|
||||
|
@ -226,7 +226,7 @@ import { i18n$ } from '../i18n.js';
|
||||
query = re.source;
|
||||
flags = re.flags;
|
||||
}
|
||||
catch (e) {
|
||||
catch {
|
||||
reParsed = null;
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,6 @@
|
||||
|
||||
/* global CodeMirror */
|
||||
|
||||
'use strict';
|
||||
|
||||
CodeMirror.defineMode('ubo-dynamic-filtering', ( ) => {
|
||||
|
||||
const validSwitches = new Set([
|
||||
@ -69,7 +67,7 @@ CodeMirror.defineMode('ubo-dynamic-filtering', ( ) => {
|
||||
hnValidator.hostname = '_';
|
||||
try {
|
||||
hnValidator.hostname = hnin;
|
||||
} catch(_) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
const hnout = hnValidator.hostname;
|
||||
|
@ -19,12 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import µb from './background.js';
|
||||
import { hostnameFromURI } from './uri-utils.js';
|
||||
import µb from './background.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
function ubologSet(state = false) {
|
||||
|
@ -508,7 +508,7 @@ class PSelectorRoot extends PSelector {
|
||||
prime(input) {
|
||||
try {
|
||||
return super.prime(input);
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ vAPI.contentScript = true;
|
||||
) {
|
||||
context = context.parent;
|
||||
}
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
vAPI.effectiveSelf = context;
|
||||
}
|
||||
@ -360,7 +360,7 @@ vAPI.SafeAnimationFrame = class {
|
||||
if ( addedNodes.length === 0 && removedNodes === false ) { return; }
|
||||
for ( const listener of getListenerIterator() ) {
|
||||
try { listener.onDOMChanged(addedNodes, removedNodes); }
|
||||
catch (ex) { }
|
||||
catch { }
|
||||
}
|
||||
addedNodes.length = 0;
|
||||
removedNodes = false;
|
||||
@ -422,7 +422,7 @@ vAPI.SafeAnimationFrame = class {
|
||||
listenerIteratorDirty = true;
|
||||
if ( domLayoutObserver === undefined ) { return; }
|
||||
try { listener.onDOMCreated(); }
|
||||
catch (ex) { }
|
||||
catch { }
|
||||
startMutationObserver();
|
||||
};
|
||||
|
||||
@ -450,7 +450,7 @@ vAPI.SafeAnimationFrame = class {
|
||||
const start = function() {
|
||||
for ( const listener of getListenerIterator() ) {
|
||||
try { listener.onDOMCreated(); }
|
||||
catch (ex) { }
|
||||
catch { }
|
||||
}
|
||||
startMutationObserver();
|
||||
};
|
||||
|
@ -91,7 +91,7 @@ const onSubscribeToList = function(details) {
|
||||
try {
|
||||
parsedURL = new URL(details.linkUrl);
|
||||
}
|
||||
catch(ex) {
|
||||
catch {
|
||||
}
|
||||
if ( parsedURL instanceof URL === false ) { return; }
|
||||
const url = parsedURL.searchParams.get('location');
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { dom } from './dom.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { dom, qs$ } from './dom.js';
|
||||
|
||||
/******************************************************************************/
|
||||
@ -118,7 +116,7 @@ if ( self.location.hash.slice(1) === 'no-dashboard.html' ) {
|
||||
if ( iframe.src !== '' ) {
|
||||
iframe.src = '';
|
||||
}
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
vAPI.defer.once(250).then(( ) => check());
|
||||
};
|
||||
|
@ -19,15 +19,13 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// This module can be dynamically loaded or spun off as a worker.
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const patches = new Map();
|
||||
const encoder = new TextEncoder();
|
||||
const reFileName = /([^\/]+?)(?:#.+)?$/;
|
||||
const reFileName = /([^/]+?)(?:#.+)?$/;
|
||||
const EMPTYLINE = '';
|
||||
|
||||
/******************************************************************************/
|
||||
@ -50,8 +48,7 @@ const basename = url => {
|
||||
const resolveURL = (path, url) => {
|
||||
try {
|
||||
return new URL(path, url);
|
||||
}
|
||||
catch(_) {
|
||||
} catch {
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -85,7 +85,7 @@ const urlToFragment = raw => {
|
||||
b.append(hn);
|
||||
fragment.append(raw.slice(0,i), b, raw.slice(i+hn.length));
|
||||
return fragment;
|
||||
} catch(_) {
|
||||
} catch {
|
||||
}
|
||||
return raw;
|
||||
};
|
||||
@ -157,7 +157,7 @@ if ( typeof details.to === 'string' && details.to.length !== 0 ) {
|
||||
let url;
|
||||
try {
|
||||
url = new URL(rawURL);
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -19,9 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
const svgRoot = document.querySelector('svg');
|
||||
@ -36,20 +33,20 @@ const shutdown = ( ) => {
|
||||
const contentInspectorChannel = ev => {
|
||||
const msg = ev.data || {};
|
||||
switch ( msg.what ) {
|
||||
case 'quitInspector': {
|
||||
shutdown();
|
||||
break;
|
||||
}
|
||||
case 'svgPaths': {
|
||||
const paths = svgRoot.children;
|
||||
paths[0].setAttribute('d', msg.paths[0]);
|
||||
paths[1].setAttribute('d', msg.paths[1]);
|
||||
paths[2].setAttribute('d', msg.paths[2]);
|
||||
paths[3].setAttribute('d', msg.paths[3]);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
case 'quitInspector': {
|
||||
shutdown();
|
||||
break;
|
||||
}
|
||||
case 'svgPaths': {
|
||||
const paths = svgRoot.children;
|
||||
paths[0].setAttribute('d', msg.paths[0]);
|
||||
paths[1].setAttribute('d', msg.paths[1]);
|
||||
paths[2].setAttribute('d', msg.paths[2]);
|
||||
paths[3].setAttribute('d', msg.paths[3]);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -21,15 +21,11 @@
|
||||
|
||||
/* global CodeMirror, diff_match_patch, uBlockDashboard */
|
||||
|
||||
'use strict';
|
||||
|
||||
import publicSuffixList from '../lib/publicsuffixlist/publicsuffixlist.js';
|
||||
|
||||
import './codemirror/ubo-dynamic-filtering.js';
|
||||
import { dom, qs$, qsa$ } from './dom.js';
|
||||
import { hostnameFromURI } from './uri-utils.js';
|
||||
import { i18n$ } from './i18n.js';
|
||||
import { dom, qs$, qsa$ } from './dom.js';
|
||||
|
||||
import './codemirror/ubo-dynamic-filtering.js';
|
||||
import publicSuffixList from '../lib/publicsuffixlist/publicsuffixlist.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -327,7 +323,7 @@ function handleImportFilePicker() {
|
||||
// https://github.com/chrisaljoudi/uBlock/issues/757
|
||||
// Support RequestPolicy rule syntax
|
||||
let result = this.result;
|
||||
let matches = /\[origins-to-destinations\]([^\[]+)/.exec(result);
|
||||
let matches = /\[origins-to-destinations\]([^[]+)/.exec(result);
|
||||
if ( matches && matches.length === 2 ) {
|
||||
result = matches[1].trim()
|
||||
.replace(/\|/g, ' ')
|
||||
@ -459,13 +455,12 @@ const onPresentationChanged = (( ) => {
|
||||
thePanes.orig.modified.join('\n'),
|
||||
thePanes.edit.modified.join('\n')
|
||||
);
|
||||
const ll = []; let il = 0, lellipsis = false;
|
||||
const rr = []; let ir = 0, rellipsis = false;
|
||||
const ll = []; let lellipsis = false;
|
||||
const rr = []; let rellipsis = false;
|
||||
for ( let i = 0; i < diffs.length; i++ ) {
|
||||
const diff = diffs[i];
|
||||
if ( diff[0] === 0 ) {
|
||||
lellipsis = rellipsis = true;
|
||||
il += 1; ir += 1;
|
||||
continue;
|
||||
}
|
||||
if ( diff[0] < 0 ) {
|
||||
@ -475,7 +470,6 @@ const onPresentationChanged = (( ) => {
|
||||
lellipsis = rellipsis = false;
|
||||
}
|
||||
ll.push(diff[1].trim());
|
||||
il += 1;
|
||||
continue;
|
||||
}
|
||||
/* diff[0] > 0 */
|
||||
@ -485,7 +479,6 @@ const onPresentationChanged = (( ) => {
|
||||
lellipsis = rellipsis = false;
|
||||
}
|
||||
rr.push(diff[1].trim());
|
||||
ir += 1;
|
||||
}
|
||||
if ( lellipsis ) { ll.push('...'); }
|
||||
if ( rellipsis ) { rr.push('...'); }
|
||||
|
@ -19,18 +19,12 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import punycode from '../lib/punycode.js';
|
||||
|
||||
import { LineIterator } from './text-utils.js';
|
||||
|
||||
import {
|
||||
decomposeHostname,
|
||||
domainFromHostname,
|
||||
} from './uri-utils.js';
|
||||
import { LineIterator } from './text-utils.js';
|
||||
import punycode from '../lib/punycode.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -73,7 +67,7 @@ const intToActionMap = new Map([
|
||||
]);
|
||||
|
||||
// For performance purpose, as simple tests as possible
|
||||
const reBadHostname = /[^0-9a-z_.\[\]:%-]/;
|
||||
const reBadHostname = /[^0-9a-z_.[\]:%-]/;
|
||||
const reNotASCII = /[^\x20-\x7F]/;
|
||||
const decomposedSource = [];
|
||||
const decomposedDestination = [];
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uMatrix
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
export const faIconsInit = (( ) => {
|
||||
|
@ -19,10 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import DynamicHostRuleFiltering from './dynamic-net-filtering.js';
|
||||
import DynamicSwitchRuleFiltering from './hnswitches.js';
|
||||
import DynamicURLRuleFiltering from './url-net-filtering.js';
|
||||
|
@ -19,16 +19,9 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* jshint bitwise: false */
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import punycode from '../lib/punycode.js';
|
||||
|
||||
import { decomposeHostname } from './uri-utils.js';
|
||||
import { LineIterator } from './text-utils.js';
|
||||
import { decomposeHostname } from './uri-utils.js';
|
||||
import punycode from '../lib/punycode.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,15 +19,11 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import logger from './logger.js';
|
||||
import µb from './background.js';
|
||||
import { sessionFirewall } from './filtering-engines.js';
|
||||
import { StaticExtFilteringHostnameDB } from './static-ext-filtering-db.js';
|
||||
import { entityFromDomain } from './uri-utils.js';
|
||||
import logger from './logger.js';
|
||||
import { sessionFirewall } from './filtering-engines.js';
|
||||
import µb from './background.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,16 +19,12 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import logger from './logger.js';
|
||||
import µb from './background.js';
|
||||
import { entityFromDomain } from './uri-utils.js';
|
||||
import { sessionFirewall } from './filtering-engines.js';
|
||||
import { StaticExtFilteringHostnameDB } from './static-ext-filtering-db.js';
|
||||
import * as sfp from './static-filtering-parser.js';
|
||||
import { StaticExtFilteringHostnameDB } from './static-ext-filtering-db.js';
|
||||
import { entityFromDomain } from './uri-utils.js';
|
||||
import logger from './logger.js';
|
||||
import { sessionFirewall } from './filtering-engines.js';
|
||||
import µb from './background.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -88,7 +88,7 @@ const contentInspectorChannel = (( ) => {
|
||||
toContentPort = browser.tabs.connect(tabId, { frameId });
|
||||
toContentPort.onMessage.addListener(onContentMessage);
|
||||
toContentPort.onDisconnect.addListener(onContentDisconnect);
|
||||
} catch(_) {
|
||||
} catch {
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2156,7 +2156,7 @@ const rowFilterer = (( ) => {
|
||||
reStr = rawPart.slice(1, -1);
|
||||
try {
|
||||
new RegExp(reStr);
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
reStr = '';
|
||||
}
|
||||
}
|
||||
@ -2937,7 +2937,7 @@ const loggerSettings = (( ) => {
|
||||
if ( Array.isArray(stored.columns) ) {
|
||||
settings.columns = stored.columns;
|
||||
}
|
||||
} catch(_) {
|
||||
} catch {
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -19,10 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import { broadcast, broadcastToAll } from './broadcast.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -21,10 +21,6 @@
|
||||
|
||||
/* global lz4BlockCodec */
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import µb from './background.js';
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -918,7 +918,7 @@ const fromBase64 = function(encoded) {
|
||||
let u8array;
|
||||
try {
|
||||
u8array = denseBase64.decode(encoded);
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
return Promise.resolve(u8array !== undefined ? u8array : encoded);
|
||||
};
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
export class MRUCache {
|
||||
constructor(maxSize) {
|
||||
this.maxSize = maxSize;
|
||||
|
@ -549,7 +549,7 @@ const PageStore = class {
|
||||
entries = await webext.webNavigation.getAllFrames({
|
||||
tabId: this.tabId
|
||||
});
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
if ( Array.isArray(entries) === false ) { return; }
|
||||
const toKeep = new Set();
|
||||
|
@ -19,11 +19,9 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import punycode from '../lib/punycode.js';
|
||||
import { i18n$ } from './i18n.js';
|
||||
import { dom, qs$, qsa$ } from './dom.js';
|
||||
import { i18n$ } from './i18n.js';
|
||||
import punycode from '../lib/punycode.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -178,11 +176,11 @@ const formatNumber = function(count) {
|
||||
// a poor's man compact form, which unfortunately is not i18n-friendly.
|
||||
count /= 1000000;
|
||||
if ( count >= 100 ) {
|
||||
count = Math.floor(count * 10) / 10;
|
||||
count = Math.floor(count * 10) / 10;
|
||||
} else if ( count > 10 ) {
|
||||
count = Math.floor(count * 100) / 100;
|
||||
count = Math.floor(count * 100) / 100;
|
||||
} else {
|
||||
count = Math.floor(count * 1000) / 1000;
|
||||
count = Math.floor(count * 1000) / 1000;
|
||||
}
|
||||
return (count).toLocaleString(undefined) + '\u2009M';
|
||||
};
|
||||
@ -469,27 +467,27 @@ function filterFirewallRows() {
|
||||
for ( const elem of elems ) {
|
||||
const on = dom.cl.has(elem, 'on');
|
||||
switch ( elem.dataset.expr ) {
|
||||
case 'not':
|
||||
not = on;
|
||||
break;
|
||||
case 'blocked':
|
||||
dom.cl.toggle(firewallElem, 'showBlocked', !not && on);
|
||||
dom.cl.toggle(firewallElem, 'hideBlocked', not && on);
|
||||
break;
|
||||
case 'allowed':
|
||||
dom.cl.toggle(firewallElem, 'showAllowed', !not && on);
|
||||
dom.cl.toggle(firewallElem, 'hideAllowed', not && on);
|
||||
break;
|
||||
case 'script':
|
||||
dom.cl.toggle(firewallElem, 'show3pScript', !not && on);
|
||||
dom.cl.toggle(firewallElem, 'hide3pScript', not && on);
|
||||
break;
|
||||
case 'frame':
|
||||
dom.cl.toggle(firewallElem, 'show3pFrame', !not && on);
|
||||
dom.cl.toggle(firewallElem, 'hide3pFrame', not && on);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 'not':
|
||||
not = on;
|
||||
break;
|
||||
case 'blocked':
|
||||
dom.cl.toggle(firewallElem, 'showBlocked', !not && on);
|
||||
dom.cl.toggle(firewallElem, 'hideBlocked', not && on);
|
||||
break;
|
||||
case 'allowed':
|
||||
dom.cl.toggle(firewallElem, 'showAllowed', !not && on);
|
||||
dom.cl.toggle(firewallElem, 'hideAllowed', not && on);
|
||||
break;
|
||||
case 'script':
|
||||
dom.cl.toggle(firewallElem, 'show3pScript', !not && on);
|
||||
dom.cl.toggle(firewallElem, 'hide3pScript', not && on);
|
||||
break;
|
||||
case 'frame':
|
||||
dom.cl.toggle(firewallElem, 'show3pFrame', !not && on);
|
||||
dom.cl.toggle(firewallElem, 'hide3pFrame', not && on);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -498,14 +496,14 @@ dom.on('#firewall .filterExpressions', 'click', 'span[data-expr]', ev => {
|
||||
const target = ev.target;
|
||||
dom.cl.toggle(target, 'on');
|
||||
switch ( target.dataset.expr ) {
|
||||
case 'blocked':
|
||||
if ( dom.cl.has(target, 'on') === false ) { break; }
|
||||
dom.cl.remove('#firewall .filterExpressions span[data-expr="allowed"]', 'on');
|
||||
break;
|
||||
case 'allowed':
|
||||
if ( dom.cl.has(target, 'on') === false ) { break; }
|
||||
dom.cl.remove('#firewall .filterExpressions span[data-expr="blocked"]', 'on');
|
||||
break;
|
||||
case 'blocked':
|
||||
if ( dom.cl.has(target, 'on') === false ) { break; }
|
||||
dom.cl.remove('#firewall .filterExpressions span[data-expr="allowed"]', 'on');
|
||||
break;
|
||||
case 'allowed':
|
||||
if ( dom.cl.has(target, 'on') === false ) { break; }
|
||||
dom.cl.remove('#firewall .filterExpressions span[data-expr="blocked"]', 'on');
|
||||
break;
|
||||
}
|
||||
filterFirewallRows();
|
||||
const elems = qsa$('#firewall .filterExpressions span[data-expr]');
|
||||
@ -1194,18 +1192,18 @@ dom.on(document, 'keydown', ev => {
|
||||
if ( ev.isComposing ) { return; }
|
||||
let bypassCache = false;
|
||||
switch ( ev.key ) {
|
||||
case 'F5':
|
||||
bypassCache = ev.ctrlKey || ev.metaKey || ev.shiftKey;
|
||||
break;
|
||||
case 'r':
|
||||
if ( (ev.ctrlKey || ev.metaKey) !== true ) { return; }
|
||||
break;
|
||||
case 'R':
|
||||
if ( (ev.ctrlKey || ev.metaKey) !== true ) { return; }
|
||||
bypassCache = true;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
case 'F5':
|
||||
bypassCache = ev.ctrlKey || ev.metaKey || ev.shiftKey;
|
||||
break;
|
||||
case 'r':
|
||||
if ( (ev.ctrlKey || ev.metaKey) !== true ) { return; }
|
||||
break;
|
||||
case 'R':
|
||||
if ( (ev.ctrlKey || ev.metaKey) !== true ) { return; }
|
||||
bypassCache = true;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
reloadTab(bypassCache);
|
||||
ev.preventDefault();
|
||||
@ -1223,7 +1221,7 @@ vAPI.localStorage.getItemAsync('popupExpandExceptions').then(exceptions => {
|
||||
expandExceptions.add(exception);
|
||||
}
|
||||
}
|
||||
catch(ex) {
|
||||
catch {
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -19,12 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import redirectableResources from './redirect-resources.js';
|
||||
import { LineIterator, orphanizeString } from './text-utils.js';
|
||||
import redirectableResources from './redirect-resources.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -49,7 +49,7 @@ export function setAttrFn(
|
||||
let elems;
|
||||
try {
|
||||
elems = document.querySelectorAll(selector);
|
||||
} catch(_) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
for ( const elem of elems ) {
|
||||
@ -259,7 +259,7 @@ export function removeAttr(
|
||||
safe.uboLog(logPrefix, `Removed attribute '${attr}'`);
|
||||
}
|
||||
}
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
};
|
||||
const mutationHandler = mutations => {
|
||||
|
@ -142,7 +142,7 @@ export function setCookieFn(
|
||||
|
||||
try {
|
||||
document.cookie = cookieParts.join('');
|
||||
} catch(_) {
|
||||
} catch {
|
||||
}
|
||||
|
||||
const done = getCookieFn(name) === value;
|
||||
|
@ -73,7 +73,7 @@ function hrefSanitizer(
|
||||
try {
|
||||
elems = document.querySelectorAll(`a[href="${href}"`);
|
||||
}
|
||||
catch(ex) {
|
||||
catch {
|
||||
}
|
||||
for ( const elem of elems ) {
|
||||
elem.setAttribute('href', text);
|
||||
@ -87,7 +87,7 @@ function hrefSanitizer(
|
||||
try {
|
||||
const url = new URL(text, document.location);
|
||||
return url.href;
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
return '';
|
||||
};
|
||||
@ -101,7 +101,7 @@ function hrefSanitizer(
|
||||
if ( value === null ) { return href }
|
||||
if ( recursive ) { return extractParam(value, source.slice(end)); }
|
||||
return value;
|
||||
} catch(x) {
|
||||
} catch {
|
||||
}
|
||||
return href;
|
||||
};
|
||||
@ -128,7 +128,7 @@ function hrefSanitizer(
|
||||
try {
|
||||
elems = document.querySelectorAll(selector);
|
||||
}
|
||||
catch(ex) {
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
for ( const elem of elems ) {
|
||||
|
@ -102,7 +102,7 @@ export function setLocalStorageItemFn(
|
||||
} else {
|
||||
storage.setItem(key, `${value}`);
|
||||
}
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
registerScriptlet(setLocalStorageItemFn, {
|
||||
|
@ -43,7 +43,7 @@ export function parseReplaceFn(s) {
|
||||
const flags = s.slice(parser.separatorEnd);
|
||||
try {
|
||||
return { re: new RegExp(pattern, flags), replacement };
|
||||
} catch(_) {
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
registerScriptlet(parseReplaceFn, {
|
||||
|
@ -95,8 +95,10 @@ export function trustedReplaceArgument(
|
||||
return context.reflect();
|
||||
}
|
||||
const argBefore = getArg(context);
|
||||
if ( safe.RegExp_test.call(reCondition, argBefore) === false ) {
|
||||
return context.reflect();
|
||||
if ( extraArgs.condition !== undefined ) {
|
||||
if ( safe.RegExp_test.call(reCondition, argBefore) === false ) {
|
||||
return context.reflect();
|
||||
}
|
||||
}
|
||||
const argAfter = replacer && typeof argBefore === 'string'
|
||||
? argBefore.replace(replacer.re, replacer.replacement)
|
||||
|
@ -127,7 +127,7 @@ export function safeSelf() {
|
||||
try {
|
||||
return new RegExp(match[1], match[2] || undefined);
|
||||
}
|
||||
catch(ex) {
|
||||
catch {
|
||||
}
|
||||
return /^/;
|
||||
},
|
||||
@ -205,7 +205,7 @@ export function safeSelf() {
|
||||
}
|
||||
};
|
||||
bc.postMessage('areyouready?');
|
||||
} catch(_) {
|
||||
} catch {
|
||||
safe.sendToLogger = (type, ...args) => {
|
||||
const text = safe.toLogText(type, ...args);
|
||||
if ( text === undefined ) { return; }
|
||||
|
@ -231,7 +231,7 @@ function abortCurrentScriptCore(
|
||||
text = self.decodeURIComponent(content);
|
||||
break;
|
||||
}
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
scriptTexts.set(elem, text);
|
||||
return text;
|
||||
@ -644,7 +644,7 @@ function matchObjectProperties(propNeedles, ...objs) {
|
||||
if ( value === undefined ) { continue; }
|
||||
if ( typeof value !== 'string' ) {
|
||||
try { value = safe.JSON_stringify(value); }
|
||||
catch(ex) { }
|
||||
catch { }
|
||||
if ( typeof value !== 'string' ) { continue; }
|
||||
}
|
||||
if ( safe.testPattern(details, value) ) { continue; }
|
||||
@ -853,7 +853,7 @@ function preventXhrFn(
|
||||
const safeDispatchEvent = (xhr, type) => {
|
||||
try {
|
||||
xhr.dispatchEvent(new Event(type));
|
||||
} catch(_) {
|
||||
} catch {
|
||||
}
|
||||
};
|
||||
const XHRBefore = XMLHttpRequest.prototype;
|
||||
@ -1295,7 +1295,7 @@ function addEventListenerDefuser(
|
||||
} else {
|
||||
h = String(callArgs[1]);
|
||||
}
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
if ( type === '' && pattern === '' ) {
|
||||
safe.uboLog(logPrefix, `Called: ${t}\n${h}\n${elementDetails(thisArg)}`);
|
||||
@ -1429,7 +1429,7 @@ function jsonPruneXhrResponse(
|
||||
} else if ( typeof innerResponse === 'string' ) {
|
||||
try {
|
||||
objBefore = safe.JSON_parse(innerResponse);
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
if ( typeof objBefore !== 'object' ) {
|
||||
@ -1681,7 +1681,7 @@ function noFetchIf(
|
||||
responseProps[p] = { value: v };
|
||||
});
|
||||
}
|
||||
catch(ex) {}
|
||||
catch { }
|
||||
} else if ( responseType !== '' ) {
|
||||
if ( validResponseProps.type.includes(responseType) ) {
|
||||
responseProps.type = { value: responseType };
|
||||
@ -1699,7 +1699,7 @@ function noFetchIf(
|
||||
let v = details[prop];
|
||||
if ( typeof v !== 'string' ) {
|
||||
try { v = safe.JSON_stringify(v); }
|
||||
catch(ex) { }
|
||||
catch { }
|
||||
}
|
||||
if ( typeof v !== 'string' ) { continue; }
|
||||
props.set(prop, v);
|
||||
@ -1721,7 +1721,7 @@ function noFetchIf(
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
if ( proceed ) {
|
||||
return context.reflect();
|
||||
@ -1823,7 +1823,7 @@ function removeClass(
|
||||
node.classList.remove(...tokens);
|
||||
safe.uboLog(logPrefix, 'Removed class(es)');
|
||||
}
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
if ( mustStay ) { return; }
|
||||
if ( document.readyState !== 'complete' ) { return; }
|
||||
@ -2342,7 +2342,7 @@ function xmlPrune(
|
||||
pruneFromDoc(xmlDoc);
|
||||
const serializer = new XMLSerializer();
|
||||
text = serializer.serializeToString(xmlDoc);
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
return text;
|
||||
};
|
||||
@ -2636,7 +2636,7 @@ function callNothrow(
|
||||
let r;
|
||||
try {
|
||||
r = Reflect.apply(...args);
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
return r;
|
||||
},
|
||||
@ -3023,7 +3023,7 @@ function trustedClickElement(
|
||||
.filter(s => {
|
||||
try {
|
||||
void querySelectorEx(s);
|
||||
} catch(_) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -3170,7 +3170,7 @@ function trustedPruneInboundObject(
|
||||
if ( extraArgs.dontOverwrite ) {
|
||||
try {
|
||||
objBefore = safe.JSON_parse(safe.JSON_stringify(targetArg));
|
||||
} catch(_) {
|
||||
} catch {
|
||||
objBefore = undefined;
|
||||
}
|
||||
}
|
||||
@ -3255,7 +3255,7 @@ function trustedReplaceOutboundText(
|
||||
let textBefore = encodedTextBefore;
|
||||
if ( extraArgs.encoding === 'base64' ) {
|
||||
try { textBefore = self.atob(encodedTextBefore); }
|
||||
catch(ex) { return encodedTextBefore; }
|
||||
catch { return encodedTextBefore; }
|
||||
}
|
||||
if ( rawPattern === '' ) {
|
||||
safe.uboLog(logPrefix, 'Decoded outbound text:\n', textBefore);
|
||||
@ -3456,7 +3456,7 @@ function trustedPreventDomBypass(
|
||||
Object.defineProperty(elem, 'contentWindow', { value: self });
|
||||
}
|
||||
safe.uboLog(logPrefix, 'Bypass prevented');
|
||||
} catch(_) {
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
return r;
|
||||
@ -3511,7 +3511,7 @@ function trustedOverrideElementMethod(
|
||||
const { thisArg } = context;
|
||||
try {
|
||||
override = thisArg.closest(selector) === thisArg;
|
||||
} catch(_) {
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
if ( override === false ) {
|
||||
|
@ -57,9 +57,9 @@ export function validateConstantFn(trusted, raw, extraArgs = {}) {
|
||||
if ( Math.abs(raw) > 0x7FFF ) { return; }
|
||||
} else if ( trusted ) {
|
||||
if ( raw.startsWith('json:') ) {
|
||||
try { value = safe.JSON_parse(raw.slice(5)); } catch(ex) { return; }
|
||||
try { value = safe.JSON_parse(raw.slice(5)); } catch { return; }
|
||||
} else if ( raw.startsWith('{') && raw.endsWith('}') ) {
|
||||
try { value = safe.JSON_parse(raw).value; } catch(ex) { return; }
|
||||
try { value = safe.JSON_parse(raw).value; } catch { return; }
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
let listEntries = Object.create(null);
|
||||
@ -212,6 +210,7 @@ const fromExtendedFilter = function(details) {
|
||||
case 8:
|
||||
// HTML filtering
|
||||
// Response header filtering
|
||||
/* fallthrough */
|
||||
case 64: {
|
||||
if ( exception !== ((fargs[2] & 0b001) !== 0) ) { break; }
|
||||
const isProcedural = (fargs[2] & 0b010) !== 0;
|
||||
|
@ -19,20 +19,15 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import staticNetFilteringEngine from './static-net-filtering.js';
|
||||
import µb from './background.js';
|
||||
import { CompiledListWriter } from './static-filtering-io.js';
|
||||
import { i18n$ } from './i18n.js';
|
||||
import * as sfp from './static-filtering-parser.js';
|
||||
|
||||
import {
|
||||
domainFromHostname,
|
||||
hostnameFromURI,
|
||||
} from './uri-utils.js';
|
||||
import { CompiledListWriter } from './static-filtering-io.js';
|
||||
import { i18n$ } from './i18n.js';
|
||||
import staticNetFilteringEngine from './static-net-filtering.js';
|
||||
import µb from './background.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -19,12 +19,8 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import { redirectEngine as reng } from './redirect-engine.js';
|
||||
import { StaticExtFilteringHostnameDB } from './static-ext-filtering-db.js';
|
||||
import { redirectEngine as reng } from './redirect-engine.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -166,7 +166,7 @@ const onScriptletMessageInjector = (( ) => {
|
||||
};
|
||||
bcSecret.postMessage('iamready!');
|
||||
self.uBO_bcSecret = bcSecret;
|
||||
} catch(_) {
|
||||
} catch {
|
||||
}
|
||||
}.toString(),
|
||||
')(',
|
||||
|
@ -19,10 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* globals browser */
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
(( ) => {
|
||||
@ -53,7 +49,7 @@ function hasSelector(selector, context = document) {
|
||||
try {
|
||||
return context.querySelector(selector) !== null;
|
||||
}
|
||||
catch(ex) {
|
||||
catch {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -65,7 +61,7 @@ function safeMatchSelector(selector, context) {
|
||||
try {
|
||||
return context.matches(safeSelector);
|
||||
}
|
||||
catch(ex) {
|
||||
catch {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -77,7 +73,7 @@ function safeQuerySelector(selector, context = document) {
|
||||
try {
|
||||
return context.querySelector(safeSelector);
|
||||
}
|
||||
catch(ex) {
|
||||
catch {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
if ( typeof vAPI === 'object' && vAPI.domFilterer ) {
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
if ( typeof vAPI === 'object' && vAPI.domFilterer ) {
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
(( ) => {
|
||||
@ -40,7 +38,7 @@ const hasSelector = selector => {
|
||||
try {
|
||||
return document.querySelector(selector) !== null;
|
||||
}
|
||||
catch(ex) {
|
||||
catch {
|
||||
}
|
||||
return false;
|
||||
};
|
||||
@ -52,7 +50,7 @@ const safeQuerySelector = selector => {
|
||||
try {
|
||||
return document.querySelector(safeSelector);
|
||||
}
|
||||
catch(ex) {
|
||||
catch {
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
@ -431,7 +431,7 @@ const elementsFromSelector = function(selector, context) {
|
||||
// plain CSS selector
|
||||
try {
|
||||
return context.querySelectorAll(selector);
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
}
|
||||
return [];
|
||||
};
|
||||
@ -443,7 +443,7 @@ const elementsFromSpecialSelector = function(selector) {
|
||||
let nodes;
|
||||
try {
|
||||
nodes = document.querySelectorAll(matches[1]);
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
nodes = [];
|
||||
}
|
||||
for ( const node of nodes ) {
|
||||
@ -772,7 +772,7 @@ const contentInspectorChannel = (( ) => {
|
||||
if ( toLoggerPort === undefined ) { return; }
|
||||
try {
|
||||
toLoggerPort.postMessage(msg);
|
||||
} catch(_) {
|
||||
} catch {
|
||||
shutdownInspector();
|
||||
}
|
||||
};
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/756
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// Scriptlets to count the number of script tags in a document.
|
||||
|
@ -52,7 +52,7 @@ const safeQuerySelectorAll = function(node, selector) {
|
||||
if ( node !== null ) {
|
||||
try {
|
||||
return node.querySelectorAll(selector);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
return [];
|
||||
@ -672,8 +672,7 @@ const filterToDOMInterface = (( ) => {
|
||||
let reFilter = null;
|
||||
try {
|
||||
reFilter = new RegExp(reStr, 'i');
|
||||
}
|
||||
catch (e) {
|
||||
} catch {
|
||||
return out;
|
||||
}
|
||||
|
||||
@ -727,8 +726,7 @@ const filterToDOMInterface = (( ) => {
|
||||
elems = document.querySelectorAll(
|
||||
raw.replace(rePseudoElements, '')
|
||||
);
|
||||
}
|
||||
catch (e) {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
const out = [];
|
||||
@ -762,7 +760,7 @@ const filterToDOMInterface = (( ) => {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
if ( !elems ) { return; }
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
(( ) => {
|
||||
@ -34,7 +32,7 @@
|
||||
let loaded = false;
|
||||
try {
|
||||
loaded = sheet.rules.length !== 0;
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
if ( loaded ) { continue; }
|
||||
const link = sheet.ownerNode || null;
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
(( ) => {
|
||||
|
@ -22,8 +22,6 @@
|
||||
// Code below has been imported from uMatrix and modified to fit uBO:
|
||||
// https://github.com/gorhill/uMatrix/blob/3f8794dd899a05e066c24066c6c0a2515d5c60d2/src/js/contentscript.js#L464-L531
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// https://github.com/gorhill/uMatrix/issues/232
|
||||
@ -46,15 +44,13 @@
|
||||
let url;
|
||||
try {
|
||||
url = new URL(refreshURL, document.baseURI);
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
if ( reSafeURL.test(url.href) === false ) { return; }
|
||||
redirectTimer = setTimeout(( ) => {
|
||||
location.assign(url.href);
|
||||
},
|
||||
parseInt(match[1], 10) * 1000 + 1
|
||||
);
|
||||
location.assign(url.href);
|
||||
}, parseInt(match[1], 10) * 1000 + 1);
|
||||
meta.parentNode.removeChild(meta);
|
||||
};
|
||||
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
(( ) => {
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
(( ) => {
|
||||
|
@ -32,7 +32,7 @@
|
||||
self.requestIdleCallback(( ) => vAPI?.bootstrap?.());
|
||||
}
|
||||
return status;
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
return true;
|
||||
})();
|
||||
|
@ -19,10 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global HTMLDocument */
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// Injected into specific web pages, those which have been pre-selected
|
||||
@ -70,7 +66,7 @@ const onMaybeSubscriptionLinkClicked = function(target) {
|
||||
title,
|
||||
});
|
||||
return true;
|
||||
} catch (_) {
|
||||
} catch {
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -19,10 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global HTMLDocument */
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// Injected into specific webpages, those which have been pre-selected
|
||||
@ -75,7 +71,7 @@ function updateStockLists(target) {
|
||||
auto,
|
||||
});
|
||||
return true;
|
||||
} catch (_) {
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,9 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { i18n$ } from './i18n.js';
|
||||
import { dom, qs$, qsa$ } from './dom.js';
|
||||
import { setAccentColor, setTheme } from './theme.js';
|
||||
import { i18n$ } from './i18n.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@ -69,7 +67,7 @@ function handleImportFilePicker() {
|
||||
throw 'Invalid';
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
catch {
|
||||
userData = undefined;
|
||||
}
|
||||
if ( userData === undefined ) {
|
||||
|
@ -19,12 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* globals browser */
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import './vapi-common.js';
|
||||
import './vapi-background.js';
|
||||
import './vapi-background-ext.js';
|
||||
@ -39,27 +33,27 @@ import './tab.js';
|
||||
import './ublock.js';
|
||||
import './utils.js';
|
||||
|
||||
import io from './assets.js';
|
||||
import µb from './background.js';
|
||||
import { filteringBehaviorChanged } from './broadcast.js';
|
||||
import cacheStorage from './cachestorage.js';
|
||||
import { ubolog } from './console.js';
|
||||
import contextMenu from './contextmenu.js';
|
||||
import { redirectEngine } from './redirect-engine.js';
|
||||
import staticFilteringReverseLookup from './reverselookup.js';
|
||||
import staticExtFilteringEngine from './static-ext-filtering.js';
|
||||
import staticNetFilteringEngine from './static-net-filtering.js';
|
||||
import webRequest from './traffic.js';
|
||||
|
||||
import {
|
||||
permanentFirewall,
|
||||
sessionFirewall,
|
||||
permanentSwitches,
|
||||
sessionSwitches,
|
||||
permanentURLFiltering,
|
||||
sessionFirewall,
|
||||
sessionSwitches,
|
||||
sessionURLFiltering,
|
||||
} from './filtering-engines.js';
|
||||
|
||||
import cacheStorage from './cachestorage.js';
|
||||
import contextMenu from './contextmenu.js';
|
||||
import { filteringBehaviorChanged } from './broadcast.js';
|
||||
import io from './assets.js';
|
||||
import { redirectEngine } from './redirect-engine.js';
|
||||
import staticExtFilteringEngine from './static-ext-filtering.js';
|
||||
import staticFilteringReverseLookup from './reverselookup.js';
|
||||
import staticNetFilteringEngine from './static-net-filtering.js';
|
||||
import { ubolog } from './console.js';
|
||||
import webRequest from './traffic.js';
|
||||
import µb from './background.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
let lastVersionInt = 0;
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
const StaticExtFilteringHostnameDB = class {
|
||||
|
@ -19,15 +19,11 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import cosmeticFilteringEngine from './cosmetic-filtering.js';
|
||||
import htmlFilteringEngine from './html-filtering.js';
|
||||
import httpheaderFilteringEngine from './httpheader-filtering.js';
|
||||
import scriptletFilteringEngine from './scriptlet-filtering.js';
|
||||
import logger from './logger.js';
|
||||
import scriptletFilteringEngine from './scriptlet-filtering.js';
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
// https://www.reddit.com/r/uBlockOrigin/comments/oq6kt5/ubo_loads_generic_filter_instead_of_specific/
|
||||
|
@ -19,8 +19,6 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
import * as cssTree from '../lib/csstree/css-tree.js';
|
||||
import { ArglistParser } from './arglist-parser.js';
|
||||
import Regex from '../lib/regexanalyzer/regex.js';
|
||||
@ -1315,7 +1313,7 @@ export class AstFilterParser {
|
||||
const value = this.getNetOptionValue(NODE_TYPE_NET_OPTION_NAME_IPADDRESS);
|
||||
if ( /^\/.+\/$/.test(value) ) {
|
||||
try { void new RegExp(value); }
|
||||
catch(_) { realBad = true; }
|
||||
catch { realBad = true; }
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1849,7 +1847,7 @@ export class AstFilterParser {
|
||||
normal = normal.replace(this.reUnicodeChars, s =>
|
||||
encodeURIComponent(s).toLowerCase()
|
||||
);
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
return normal;
|
||||
@ -2827,7 +2825,7 @@ export class AstFilterParser {
|
||||
try {
|
||||
this.punycoder.hostname = hn;
|
||||
hn = this.punycoder.hostname;
|
||||
} catch (_) {
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
if ( hn === '_' || hn === '' ) { return ''; }
|
||||
@ -2951,7 +2949,7 @@ export function parseQueryPruneValue(arg) {
|
||||
try {
|
||||
out.re = new RegExp(match[1], match[2] || '');
|
||||
}
|
||||
catch(ex) {
|
||||
catch {
|
||||
out.bad = true;
|
||||
}
|
||||
return out;
|
||||
@ -2960,7 +2958,7 @@ export function parseQueryPruneValue(arg) {
|
||||
if ( s.startsWith('|') ) {
|
||||
try {
|
||||
out.re = new RegExp('^' + s.slice(1), 'i');
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
out.bad = true;
|
||||
}
|
||||
return out;
|
||||
@ -2990,7 +2988,7 @@ export function parseHeaderValue(arg) {
|
||||
try {
|
||||
out.re = new RegExp(match[1], match[2] || '');
|
||||
}
|
||||
catch(ex) {
|
||||
catch {
|
||||
out.bad = true;
|
||||
}
|
||||
}
|
||||
@ -3022,7 +3020,7 @@ export function parseReplaceValue(s) {
|
||||
const flags = s.slice(parser.separatorEnd);
|
||||
try {
|
||||
return { re: new RegExp(pattern, flags), replacement };
|
||||
} catch(_) {
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
|
||||
@ -4056,7 +4054,7 @@ class ExtSelectorCompiler {
|
||||
try {
|
||||
const expr = doc.createExpression(r.s, null);
|
||||
expr.evaluate(doc, XPathResult.ANY_UNORDERED_NODE_TYPE);
|
||||
} catch (e) {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
return r.s;
|
||||
@ -4212,7 +4210,7 @@ export const utils = (( ) => {
|
||||
regexAnalyzer(reStr, false).tree()
|
||||
);
|
||||
}
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -4223,7 +4221,7 @@ export const utils = (( ) => {
|
||||
let tree;
|
||||
try {
|
||||
tree = regexAnalyzer(reStr, false).tree();
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
const isRE2 = node => {
|
||||
@ -4254,7 +4252,7 @@ export const utils = (( ) => {
|
||||
s = this.tokenizableStrFromNode(
|
||||
regexAnalyzer(reStr, false).tree()
|
||||
);
|
||||
} catch(ex) {
|
||||
} catch {
|
||||
}
|
||||
// Process optional sequences
|
||||
const reOptional = /[\x02\x03]+/;
|
||||
@ -4316,7 +4314,7 @@ export const utils = (( ) => {
|
||||
const toURL = url => {
|
||||
try {
|
||||
return new URL(url.trim());
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -3453,7 +3453,7 @@ class FilterCompiler {
|
||||
try {
|
||||
const re = new RegExp(s);
|
||||
return re.source;
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
}
|
||||
return '';
|
||||
}
|
||||
@ -5503,7 +5503,7 @@ StaticNetFilteringEngine.prototype.filterQuery = function(fctxt, out = []) {
|
||||
for ( const [ key, raw ] of params ) {
|
||||
let value = raw;
|
||||
try { value = decodeURIComponent(value); }
|
||||
catch(ex) { }
|
||||
catch { }
|
||||
if ( re.test(`${key}=${value}`) === not ) { continue; }
|
||||
if ( isException === false ) { params.delete(key); }
|
||||
filtered = true;
|
||||
|
@ -435,7 +435,7 @@ onBroadcast(msg => {
|
||||
try {
|
||||
const url = new URL(prefix);
|
||||
if ( url.hostname.length > 0 ) { return url.href; }
|
||||
} catch(_) {
|
||||
} catch {
|
||||
}
|
||||
}).filter(prefix => prefix !== undefined);
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user