mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-14 23:12:28 +02:00
Prevent :others()
from hiding html
tag
Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/3060
This commit is contained in:
parent
c65dbdbffa
commit
9a104bcbd2
@ -30,6 +30,9 @@ if (
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
const nonVisualElements = {
|
const nonVisualElements = {
|
||||||
|
head: true,
|
||||||
|
link: true,
|
||||||
|
meta: true,
|
||||||
script: true,
|
script: true,
|
||||||
style: true,
|
style: true,
|
||||||
};
|
};
|
||||||
@ -196,28 +199,27 @@ class PSelectorOthersTask extends PSelectorTask {
|
|||||||
const toKeep = new Set(this.targets);
|
const toKeep = new Set(this.targets);
|
||||||
const toDiscard = new Set();
|
const toDiscard = new Set();
|
||||||
const body = document.body;
|
const body = document.body;
|
||||||
|
const head = document.head;
|
||||||
let discard = null;
|
let discard = null;
|
||||||
for ( let keep of this.targets ) {
|
for ( let keep of this.targets ) {
|
||||||
while ( keep !== null && keep !== body ) {
|
while ( keep !== null && keep !== body && keep !== head ) {
|
||||||
toKeep.add(keep);
|
toKeep.add(keep);
|
||||||
toDiscard.delete(keep);
|
toDiscard.delete(keep);
|
||||||
discard = keep.previousElementSibling;
|
discard = keep.previousElementSibling;
|
||||||
while ( discard !== null ) {
|
while ( discard !== null ) {
|
||||||
if (
|
if ( nonVisualElements[discard.localName] !== true ) {
|
||||||
nonVisualElements[discard.localName] !== true &&
|
if ( toKeep.has(discard) === false ) {
|
||||||
toKeep.has(discard) === false
|
toDiscard.add(discard);
|
||||||
) {
|
}
|
||||||
toDiscard.add(discard);
|
|
||||||
}
|
}
|
||||||
discard = discard.previousElementSibling;
|
discard = discard.previousElementSibling;
|
||||||
}
|
}
|
||||||
discard = keep.nextElementSibling;
|
discard = keep.nextElementSibling;
|
||||||
while ( discard !== null ) {
|
while ( discard !== null ) {
|
||||||
if (
|
if ( nonVisualElements[discard.localName] !== true ) {
|
||||||
nonVisualElements[discard.localName] !== true &&
|
if ( toKeep.has(discard) === false ) {
|
||||||
toKeep.has(discard) === false
|
toDiscard.add(discard);
|
||||||
) {
|
}
|
||||||
toDiscard.add(discard);
|
|
||||||
}
|
}
|
||||||
discard = discard.nextElementSibling;
|
discard = discard.nextElementSibling;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user