A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/gorhill/uBlock/commit/64c1f8767ca42c6c0681f571ae87a20343c12b19 below:

Add ability to control trusted status of filter lists · gorhill/uBlock@64c1f87 · GitHub

@@ -39,20 +39,32 @@ let hintHelperRegistered = false;

39 39 40 40

/******************************************************************************/

41 41 42 +

const trustedScriptletTokens = new Set();

42 43

let trustedSource = false;

43 44 44 -

CodeMirror.defineOption('trustedSource', false, (cm, state) => {

45 -

trustedSource = state;

45 +

CodeMirror.defineOption('trustedSource', false, (cm, value) => {

46 +

trustedSource = value;

46 47

self.dispatchEvent(new Event('trustedSource'));

47 48

});

48 49 50 +

CodeMirror.defineOption('trustedScriptletTokens', trustedScriptletTokens, (cm, tokens) => {

51 +

if ( tokens === undefined || tokens === null ) { return; }

52 +

if ( typeof tokens[Symbol.iterator] !== 'function' ) { return; }

53 +

trustedScriptletTokens.clear();

54 +

for ( const token of tokens ) {

55 +

trustedScriptletTokens.add(token);

56 +

}

57 +

self.dispatchEvent(new Event('trustedScriptletTokens'));

58 +

});

59 + 49 60

/******************************************************************************/

50 61 51 62

CodeMirror.defineMode('ubo-static-filtering', function() {

52 63

const astParser = new sfp.AstFilterParser({

53 64

interactive: true,

54 -

trustedSource,

55 65

nativeCssHas: vAPI.webextFlavor.env.includes('native_css_has'),

66 +

trustedSource,

67 +

trustedScriptletTokens,

56 68

});

57 69

const astWalker = astParser.getWalker();

58 70

let currentWalkerNode = 0;

@@ -218,6 +230,10 @@ CodeMirror.defineMode('ubo-static-filtering', function() {

218 230

astParser.options.trustedSource = trustedSource;

219 231

});

220 232 233 +

self.addEventListener('trustedScriptletTokens', ( ) => {

234 +

astParser.options.trustedScriptletTokens = trustedScriptletTokens;

235 +

});

236 + 221 237

return {

222 238

lineComment: '!',

223 239

token: function(stream) {

@@ -679,6 +695,8 @@ CodeMirror.registerHelper('fold', 'ubo-static-filtering', (( ) => {

679 695

const astParser = new sfp.AstFilterParser({

680 696

interactive: true,

681 697

nativeCssHas: vAPI.webextFlavor.env.includes('native_css_has'),

698 +

trustedSource,

699 +

trustedScriptletTokens,

682 700

});

683 701 684 702

const changeset = [];

@@ -715,6 +733,9 @@ CodeMirror.registerHelper('fold', 'ubo-static-filtering', (( ) => {

715 733

case sfp.AST_ERROR_IF_TOKEN_UNKNOWN:

716 734

msg = `${msg}: Unknown preparsing token`;

717 735

break;

736 +

case sfp.AST_ERROR_UNTRUSTED_SOURCE:

737 +

msg = `${msg}: Filter requires trusted source`;

738 +

break;

718 739

default:

719 740

if ( astParser.isCosmeticFilter() && astParser.result.error ) {

720 741

msg = `${msg}: ${astParser.result.error}`;

@@ -994,6 +1015,10 @@ CodeMirror.registerHelper('fold', 'ubo-static-filtering', (( ) => {

994 1015

astParser.options.trustedSource = trustedSource;

995 1016

});

996 1017 1018 +

self.addEventListener('trustedScriptletTokens', ( ) => {

1019 +

astParser.options.trustedScriptletTokens = trustedScriptletTokens;

1020 +

});

1021 + 997 1022

CodeMirror.defineInitHook(cm => {

998 1023

cm.on('changes', onChanges);

999 1024

cm.on('beforeChange', onBeforeChanges);


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4