mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-14 23:12:28 +02:00
Avoid redundant logger entries for scriptlet injection
Report only when the scriptlets have been successfully injected.
This commit is contained in:
parent
47cb7baff0
commit
8a34425ca5
@ -89,36 +89,34 @@ const contentscriptCode = (( ) => {
|
|||||||
const parts = [
|
const parts = [
|
||||||
'(',
|
'(',
|
||||||
function(hostname, scriptlets) {
|
function(hostname, scriptlets) {
|
||||||
|
const doc = document;
|
||||||
if (
|
if (
|
||||||
document.location === null ||
|
doc.location === null ||
|
||||||
hostname !== document.location.hostname ||
|
hostname !== doc.location.hostname ||
|
||||||
typeof self.uBO_scriptletsInjected === 'boolean'
|
typeof self.uBO_scriptletsInjected === 'boolean'
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const injectScriptlets = function(d) {
|
let script;
|
||||||
let script;
|
try {
|
||||||
try {
|
script = doc.createElement('script');
|
||||||
script = d.createElement('script');
|
script.appendChild(doc.createTextNode(
|
||||||
script.appendChild(d.createTextNode(
|
decodeURIComponent(scriptlets))
|
||||||
decodeURIComponent(scriptlets))
|
);
|
||||||
);
|
(doc.head || doc.documentElement).appendChild(script);
|
||||||
(d.head || d.documentElement).appendChild(script);
|
self.uBO_scriptletsInjected = true;
|
||||||
self.uBO_scriptletsInjected = true;
|
} catch (ex) {
|
||||||
} catch (ex) {
|
}
|
||||||
}
|
if ( script ) {
|
||||||
if ( script ) {
|
script.remove();
|
||||||
script.remove();
|
script.textContent = '';
|
||||||
script.textContent = '';
|
}
|
||||||
}
|
if ( typeof self.uBO_scriptletsInjected === 'boolean' ) { return 0; }
|
||||||
};
|
|
||||||
injectScriptlets(document);
|
|
||||||
}.toString(),
|
}.toString(),
|
||||||
')(',
|
')(',
|
||||||
'"', 'hostname-slot', '", ',
|
'"', 'hostname-slot', '", ',
|
||||||
'"', 'scriptlets-slot', '"',
|
'"', 'scriptlets-slot', '"',
|
||||||
');',
|
');',
|
||||||
'\n0;',
|
|
||||||
];
|
];
|
||||||
return {
|
return {
|
||||||
parts: parts,
|
parts: parts,
|
||||||
|
Loading…
Reference in New Issue
Block a user