mirror of https://github.com/gorhill/uBlock.git
Prevent duplicate inline-script entries in the logger
Related discussion: - https://www.reddit.com/r/uBlockOrigin/comments/c4340z/filter_problem/ervpjd8/
This commit is contained in:
parent
5caa369229
commit
8e7384ba84
|
@ -202,7 +202,8 @@ vAPI.SafeAnimationFrame.prototype = {
|
||||||
// are properly reported in the logger.
|
// are properly reported in the logger.
|
||||||
|
|
||||||
{
|
{
|
||||||
const events = new Set();
|
const newEvents = new Set();
|
||||||
|
const allEvents = new Set();
|
||||||
let timer;
|
let timer;
|
||||||
|
|
||||||
const send = function() {
|
const send = function() {
|
||||||
|
@ -212,14 +213,17 @@ vAPI.SafeAnimationFrame.prototype = {
|
||||||
what: 'securityPolicyViolation',
|
what: 'securityPolicyViolation',
|
||||||
type: 'net',
|
type: 'net',
|
||||||
docURL: document.location.href,
|
docURL: document.location.href,
|
||||||
violations: Array.from(events),
|
violations: Array.from(newEvents),
|
||||||
},
|
},
|
||||||
response => {
|
response => {
|
||||||
if ( response === true ) { return; }
|
if ( response === true ) { return; }
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
events.clear();
|
for ( const event of newEvents ) {
|
||||||
|
allEvents.add(event);
|
||||||
|
}
|
||||||
|
newEvents.clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendAsync = function() {
|
const sendAsync = function() {
|
||||||
|
@ -233,16 +237,19 @@ vAPI.SafeAnimationFrame.prototype = {
|
||||||
const listener = function(ev) {
|
const listener = function(ev) {
|
||||||
if ( ev.isTrusted !== true ) { return; }
|
if ( ev.isTrusted !== true ) { return; }
|
||||||
if ( ev.disposition !== 'enforce' ) { return; }
|
if ( ev.disposition !== 'enforce' ) { return; }
|
||||||
events.add(JSON.stringify({
|
const json = JSON.stringify({
|
||||||
url: ev.blockedURL || ev.blockedURI,
|
url: ev.blockedURL || ev.blockedURI,
|
||||||
policy: ev.originalPolicy,
|
policy: ev.originalPolicy,
|
||||||
directive: ev.effectiveDirective || ev.violatedDirective,
|
directive: ev.effectiveDirective || ev.violatedDirective,
|
||||||
}));
|
});
|
||||||
|
if ( allEvents.has(json) ) { return; }
|
||||||
|
newEvents.add(json);
|
||||||
sendAsync();
|
sendAsync();
|
||||||
};
|
};
|
||||||
|
|
||||||
const stop = function() {
|
const stop = function() {
|
||||||
events.clear();
|
newEvents.clear();
|
||||||
|
allEvents.clear();
|
||||||
if ( timer !== undefined ) {
|
if ( timer !== undefined ) {
|
||||||
self.cancelIdleCallback(timer);
|
self.cancelIdleCallback(timer);
|
||||||
timer = undefined;
|
timer = undefined;
|
||||||
|
|
Loading…
Reference in New Issue