Skip to content

Instantly share code, notes, and snippets.

@kdzwinel kdzwinel/filter-out-ads.js
Last active Mar 22, 2018

Embed
What would you like to do?
TrackJS custom onError callback that tries to filter out noise from ads
// ES5 for compat
window._trackJs.onError = function(error) {
try {
var fileURL = new URL(error.file);
if (fileURL) {
// safelist includes current domain + some third-parties we want to track
var safe = domainSafelist.some(function (domain) {
return fileURL.host.endsWith(domain);
});
if (!safe) {
// block
return false;
}
}
} catch(e) {
// if somethings goes wrong, don't block the request
}
return true;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.