Optimized fall-back reporting for non-HTTP documents and included script type.
This commit is contained in:
parent
6fadd5c4f9
commit
0790ad885e
|
@ -169,12 +169,13 @@ if (!/^https:/.test(location.protocol)) {
|
||||||
// let's emulate them using mutation observers
|
// let's emulate them using mutation observers
|
||||||
const checked = new Set();
|
const checked = new Set();
|
||||||
const checkSrc = async (node) => {
|
const checkSrc = async (node) => {
|
||||||
if (!('src' in node && node.parentNode)) {
|
if (!(node.src && node.parentNode)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const type = node instanceof HTMLMediaElement ? "media"
|
const type = node instanceof HTMLMediaElement ? "media"
|
||||||
: node instanceof HTMLIFrameElement ? "sub_frame"
|
: node instanceof HTMLIFrameElement ? "sub_frame"
|
||||||
: node instanceof HTMLObjectElement || node instanceof HTMLEmbedElement ? "object"
|
: node instanceof HTMLObjectElement || node instanceof HTMLEmbedElement ? "object"
|
||||||
|
: node instanceof HTMLScriptElement ? "script"
|
||||||
: "";
|
: "";
|
||||||
if (!type) {
|
if (!type) {
|
||||||
return;
|
return;
|
||||||
|
@ -199,6 +200,8 @@ if (!/^https:/.test(location.protocol)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const watch = () => {
|
||||||
|
[...document.querySelectorAll("media, video, audio, iframe, frame, object, embed, script")].forEach(checkSrc);
|
||||||
const observer = new MutationObserver(mutationsCallback);
|
const observer = new MutationObserver(mutationsCallback);
|
||||||
observer.observe(document.documentElement, {
|
observer.observe(document.documentElement, {
|
||||||
childList: true,
|
childList: true,
|
||||||
|
@ -206,6 +209,12 @@ if (!/^https:/.test(location.protocol)) {
|
||||||
attributeFilter: ["src"],
|
attributeFilter: ["src"],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (document.readyState === "complete") {
|
||||||
|
watch();
|
||||||
|
} else {
|
||||||
|
addEventListener("DOMContentLoaded", watch, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ns.on("capabilities", () => {
|
ns.on("capabilities", () => {
|
||||||
seen.record({
|
seen.record({
|
||||||
|
|
Loading…
Reference in New Issue