mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
Minor code review
This commit is contained in:
parent
1285f78e05
commit
aceaea0122
@ -1534,27 +1534,27 @@
|
|||||||
|
|
||||||
/// damoh-defuser.js
|
/// damoh-defuser.js
|
||||||
(function() {
|
(function() {
|
||||||
var handled = new WeakSet();
|
const handled = new WeakSet();
|
||||||
var asyncTimer;
|
let asyncTimer;
|
||||||
var cleanVideo = function() {
|
const cleanVideo = function() {
|
||||||
asyncTimer = undefined;
|
asyncTimer = undefined;
|
||||||
var v = document.querySelector('video');
|
const v = document.querySelector('video');
|
||||||
if ( v === null ) { return; }
|
if ( v === null ) { return; }
|
||||||
if ( handled.has(v) ) { return; }
|
if ( handled.has(v) ) { return; }
|
||||||
handled.add(v);
|
handled.add(v);
|
||||||
v.pause();
|
v.pause();
|
||||||
v.controls = true;
|
v.controls = true;
|
||||||
var el = v.querySelector('meta[itemprop="contentURL"][content]');
|
let el = v.querySelector('meta[itemprop="contentURL"][content]');
|
||||||
if ( el === null ) { return; }
|
if ( el === null ) { return; }
|
||||||
v.src = el.getAttribute('content');
|
v.src = el.getAttribute('content');
|
||||||
el = v.querySelector('meta[itemprop="thumbnailUrl"][content]');
|
el = v.querySelector('meta[itemprop="thumbnailUrl"][content]');
|
||||||
if ( el !== null ) { v.poster = el.getAttribute('content'); }
|
if ( el !== null ) { v.poster = el.getAttribute('content'); }
|
||||||
};
|
};
|
||||||
var cleanVideoAsync = function() {
|
const cleanVideoAsync = function() {
|
||||||
if ( asyncTimer !== undefined ) { return; }
|
if ( asyncTimer !== undefined ) { return; }
|
||||||
asyncTimer = window.requestAnimationFrame(cleanVideo);
|
asyncTimer = window.requestAnimationFrame(cleanVideo);
|
||||||
};
|
};
|
||||||
var observer = new MutationObserver(cleanVideoAsync);
|
const observer = new MutationObserver(cleanVideoAsync);
|
||||||
observer.observe(document, { childList: true, subtree: true });
|
observer.observe(document, { childList: true, subtree: true });
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
@ -473,9 +473,7 @@ vAPI.injectScriptlet = function(doc, text) {
|
|||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
}
|
}
|
||||||
if ( script ) {
|
if ( script ) {
|
||||||
if ( script.parentNode ) {
|
script.remove();
|
||||||
script.parentNode.removeChild(script);
|
|
||||||
}
|
|
||||||
script.textContent = '';
|
script.textContent = '';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1171,11 +1169,11 @@ vAPI.DOMFilterer = class {
|
|||||||
// Look-up safe-only selectors to mitigate probability of
|
// Look-up safe-only selectors to mitigate probability of
|
||||||
// html/body elements of erroneously being targeted.
|
// html/body elements of erroneously being targeted.
|
||||||
const ids = [], classes = [];
|
const ids = [], classes = [];
|
||||||
if (document.documentElement !== null) {
|
if ( document.documentElement !== null ) {
|
||||||
idFromNode(document.documentElement, ids);
|
idFromNode(document.documentElement, ids);
|
||||||
classesFromNode(document.documentElement, classes);
|
classesFromNode(document.documentElement, classes);
|
||||||
}
|
}
|
||||||
if (document.body !== null) {
|
if ( document.body !== null ) {
|
||||||
idFromNode(document.body, ids);
|
idFromNode(document.body, ids);
|
||||||
classesFromNode(document.body, classes);
|
classesFromNode(document.body, classes);
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ const domLayout = (function() {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// sibling
|
// sibling
|
||||||
if (node instanceof Element) {
|
if ( node instanceof Element ) {
|
||||||
if ( node.nextElementSibling === null ) {
|
if ( node.nextElementSibling === null ) {
|
||||||
do {
|
do {
|
||||||
node = stack.pop();
|
node = stack.pop();
|
||||||
@ -549,7 +549,7 @@ const cosmeticFilterMapper = (function() {
|
|||||||
|
|
||||||
const reset = function() {
|
const reset = function() {
|
||||||
roRedNodes.clear();
|
roRedNodes.clear();
|
||||||
if (document.documentElement !== null) {
|
if ( document.documentElement !== null ) {
|
||||||
incremental(document.documentElement);
|
incremental(document.documentElement);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -74,7 +74,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( surveyResults.scriptCount === -1 ) {
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/1756
|
||||||
|
// Mind that there might be no body element.
|
||||||
|
if ( surveyResults.scriptCount === -1 && document.body !== null ) {
|
||||||
surveyResults.scriptCount = 0;
|
surveyResults.scriptCount = 0;
|
||||||
const onHandlers = new Set([
|
const onHandlers = new Set([
|
||||||
'onabort', 'onblur', 'oncancel', 'oncanplay',
|
'onabort', 'onblur', 'oncancel', 'oncanplay',
|
||||||
|
Loading…
Reference in New Issue
Block a user