Convert new setTimeout-if scriptlet to blacklist approach

As per feedback from filter list maintainers, the
whitelist approach has been deemed to confusing.

The scriptlet has been renamed `no-setTimeout-if`
alias `nostif` to reflect the blacklist approach.

`setInterval-if` has been Similarly changed to
`no-setInterval-if` alias `nosiif`.
This commit is contained in:
Raymond Hill 2019-09-15 11:01:50 -04:00
parent df49616ae8
commit 9367a6015b
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 23 additions and 27 deletions

View File

@ -582,8 +582,8 @@
})();
/// setInterval-if.js
/// alias siif.js
/// no-setInterval-if.js
/// alias nosiif.js
(function() {
let needle = '{{1}}';
const needleNot = needle.charAt(0) === '!';
@ -611,14 +611,12 @@
let defuse = false;
if ( log !== undefined ) {
log('uBO: setInterval("%s", %s)', a, b);
} else if ( needle === '' && needleNot || isNaN(delay) && delayNot ) {
defuse = true;
} else if ( isNaN(delay) ) {
defuse = reNeedle.test(a) === needleNot;
defuse = reNeedle.test(a) !== needleNot;
} else if ( needle === '' ) {
defuse = (b === delay) === delayNot;
} else if ( reNeedle.test(a) === needleNot || (b === delay) === delayNot ) {
defuse = true;
defuse = (b === delay) !== delayNot;
} else {
defuse = reNeedle.test(a) !== needleNot && (b === delay) !== delayNot;
}
if ( defuse ) {
args[0] = function(){};
@ -655,8 +653,8 @@
})();
/// setTimeout-if.js
/// alias stif.js
/// no-setTimeout-if.js
/// alias nostif.js
(function() {
let needle = '{{1}}';
const needleNot = needle.charAt(0) === '!';
@ -684,14 +682,12 @@
let defuse = false;
if ( log !== undefined ) {
log('uBO: setTimeout("%s", %s)', a, b);
} else if ( needle === '' && needleNot || isNaN(delay) && delayNot ) {
defuse = true;
} else if ( isNaN(delay) ) {
defuse = reNeedle.test(a) === needleNot;
defuse = reNeedle.test(a) !== needleNot;
} else if ( needle === '' ) {
defuse = (b === delay) === delayNot;
} else if ( reNeedle.test(a) === needleNot || (b === delay) === delayNot ) {
defuse = true;
defuse = (b === delay) !== delayNot;
} else {
defuse = reNeedle.test(a) !== needleNot && (b === delay) !== delayNot;
}
if ( defuse ) {
args[0] = function(){};

View File

@ -162,21 +162,21 @@ time. When you try a filter, ensure the result is what is expected.</p>
const hostname = self.location.hostname;
const fragment = document.createDocumentFragment();
const filters = [
[ [ '!bad' ], 'GGGG' ],
[ [ 'good' ], 'GGGG' ],
[ [ '', '!33' ], 'GRRG' ],
[ [ '', '66' ], 'GRRG' ],
[ [ '!bad', '!33' ], 'GGRG' ],
[ [ 'good', '66' ], 'GGRG' ],
[ [ '!bad', '33' ], 'GGGR' ],
[ [ 'good', '!66' ], 'GGGR' ],
[ [ 'bad', '!33' ], 'GRRR' ],
[ [ '!good', '66' ], 'GRRR' ],
[ [ 'bad' ], 'GGGG' ],
[ [ '!good' ], 'GGGG' ],
[ [ '', '33' ], 'GRRG' ],
[ [ '', '!66' ], 'GRRG' ],
[ [ 'bad', '33' ], 'GRGG' ],
[ [ '!good', '!66' ], 'GRGG' ],
[ [ 'bad', '!33' ], 'RGGG' ],
[ [ '!good', '66' ], 'RGGG' ],
[ [ '!bad', '33' ], 'RRRG' ],
[ [ 'good', '!66' ], 'RRRG' ],
];
for ( const [ args, result ] of filters ) {
const tr = document.createElement('tr');
let td = document.createElement('td');
td.textContent = `${hostname}##+js(stif, ${args.join(', ')})`;
td.textContent = `${hostname}##+js(nostif, ${args.join(', ')})`;
tr.appendChild(td);
td = document.createElement('td');
for ( let i = 0; i < result.length; i++ ) {