Skip to content

Commit

Permalink
fix console.error calls
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Nov 16, 2022
1 parent 3ae7455 commit cb97abe
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
18 changes: 12 additions & 6 deletions src/redirects/google-ima3.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* eslint-disable func-names, no-underscore-dangle */
import { hit, noopFunc } from '../helpers/index';
import {
hit,
noopFunc,
logVerbose,
} from '../helpers/index';

/**
* @redirect google-ima3
Expand Down Expand Up @@ -114,8 +118,7 @@ export function GoogleIma3(source) {
try {
listener(e);
} catch (r) {
// eslint-disable-next-line no-console
console.error(r);
logVerbose(r, source.verbose);
}
}
};
Expand Down Expand Up @@ -165,8 +168,7 @@ export function GoogleIma3(source) {
try {
this._dispatch(new ima.AdEvent(type));
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
logVerbose(e, source.verbose);
}
}
};
Expand Down Expand Up @@ -478,4 +480,8 @@ export function GoogleIma3(source) {

GoogleIma3.names = ['google-ima3'];

GoogleIma3.injections = [hit, noopFunc];
GoogleIma3.injections = [
hit,
noopFunc,
logVerbose,
];
14 changes: 11 additions & 3 deletions src/scriptlets/prevent-adfly.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* eslint-disable func-names */
import { hit, setPropertyAccess } from '../helpers/index';
import {
hit,
setPropertyAccess,
logVerbose,
} from '../helpers/index';

/**
* @scriptlet prevent-adfly
Expand Down Expand Up @@ -79,7 +83,7 @@ export function preventAdfly(source) {
if (result) {
hit(source);
} else {
window.console.error('Failed to set up prevent-adfly scriptlet');
logVerbose('Failed to set up prevent-adfly scriptlet', source.verbose);
}
}

Expand All @@ -91,4 +95,8 @@ preventAdfly.names = [
'ubo-adfly-defuser',
];

preventAdfly.injections = [setPropertyAccess, hit];
preventAdfly.injections = [
setPropertyAccess,
hit,
logVerbose,
];
4 changes: 2 additions & 2 deletions tests/scriptlets/prevent-xhr.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-underscore-dangle, no-console */
import { runScriptlet, clearGlobalProps } from '../helpers';
import { startsWith } from '../../src/helpers/string-utils';
import { startsWith, logMessage } from '../../src/helpers';

const { test, module } = QUnit;
const name = 'prevent-xhr';
Expand Down Expand Up @@ -549,7 +549,7 @@ if (isSupported) {
try {
createImg.setAttribute('src', window.URL.createObjectURL(xhr.response));
} catch (error) {
console.error(error);
logMessage(error);
}
document.body.appendChild(createImg);
assert.strictEqual(xhr.readyState, 4, 'Response done');
Expand Down

0 comments on commit cb97abe

Please sign in to comment.