Skip to content

Instantly share code, notes, and snippets.

@nicjansma
Last active September 5, 2017 20:36
Show Gist options
  • Save nicjansma/8db3aafbd5a95c7a64513abd6bfa6066 to your computer and use it in GitHub Desktop.
Save nicjansma/8db3aafbd5a95c7a64513abd6bfa6066 to your computer and use it in GitHub Desktop.
Boomerang AutoXHR Whitelist (requires 1.420 or later)
/**
* Boomerang XHR whitelist
*/
function addWhitelistFilter() {
if (window.BOOMR &&
window.BOOMR.version &&
window.BOOMR.plugins &&
window.BOOMR.plugins.AutoXHR &&
typeof BOOMR.plugins.AutoXHR.addExcludeFilter === "function") {
// This function is called for each XHR.
// Return true to ignore the XHR, or false to track the XHR.
function whitelistFilter(url) {
// Example of tracking 'hello/api'
if (url.href && url.href.indexOf("hello/api") > -1) {
return false;
}
// All other URLs will be ignored
return true;
}
// Register the filter
BOOMR.plugins.AutoXHR.addExcludeFilter(whitelistFilter, window, "Whitelist Filter");
return true;
}
}
// try to add the filter, waiting for Boomerang to arrive on the page if it isn't yet
if (!addWhitelistFilter()) {
if (document.addEventListener) {
document.addEventListener("onBoomerangLoaded", addWhitelistFilter);
}
else if (document.attachEvent) {
document.attachEvent("onpropertychange", function(e){
e = e || window.event;
if (e && e.propertyName === "onBoomerangLoaded") {
addWhitelistFilter();
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment