mirror of https://github.com/gorhill/uBlock.git
Add support for "remove all properties" in json-prune scriptlet
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1545
This commit is contained in:
parent
9a94ba0a22
commit
d338e4c4b6
|
@ -367,6 +367,10 @@
|
||||||
// When no "prune paths" argument is provided, the scriptlet is
|
// When no "prune paths" argument is provided, the scriptlet is
|
||||||
// used for logging purpose and the "needle paths" argument is
|
// used for logging purpose and the "needle paths" argument is
|
||||||
// used to filter logging output.
|
// used to filter logging output.
|
||||||
|
//
|
||||||
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/1545
|
||||||
|
// - Add support for "remove everything if needle matches" case
|
||||||
|
//
|
||||||
(function() {
|
(function() {
|
||||||
const rawPrunePaths = '{{1}}';
|
const rawPrunePaths = '{{1}}';
|
||||||
const rawNeedlePaths = '{{2}}';
|
const rawNeedlePaths = '{{2}}';
|
||||||
|
@ -401,9 +405,15 @@
|
||||||
}
|
}
|
||||||
const pos = chain.indexOf('.');
|
const pos = chain.indexOf('.');
|
||||||
if ( pos === -1 ) {
|
if ( pos === -1 ) {
|
||||||
const found = owner.hasOwnProperty(chain);
|
if ( prune === false ) {
|
||||||
if ( found === false ) { return false; }
|
return owner.hasOwnProperty(chain);
|
||||||
if ( prune ) {
|
}
|
||||||
|
if ( chain === '*' ) {
|
||||||
|
for ( const key in owner ) {
|
||||||
|
if ( owner.hasOwnProperty(key) === false ) { continue; }
|
||||||
|
delete owner[key];
|
||||||
|
}
|
||||||
|
} else if ( owner.hasOwnProperty(chain) ) {
|
||||||
delete owner[chain];
|
delete owner[chain];
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue