Edit: For microAjax, look up its documentation. I'd imagine in the response you can find the response code. If the code is 200
it's a success, and you can run window.open()
. Otherwise, the request is likely being blocked.
var request = new XMLHttpRequest();
request.onreadystatechange = function() {
if(request.readyState === 4 && request.status === 200 ) {
console.log('No blocker');
}
else if(request.readyState === 4 && request.status === 0){
console.log('Blocker exists');
}
};
request.open("GET","pathTo/ads.html");
request.send();
This uses a local URL; I initially thought using external URLs was a good idea, but if they're made invalid by their owners you'll get false positives.
I tested this using Adblock Plus and it works. If this is a URL blocked by Ghostery it should work as well; otherwise, you can try different URLs to see what's blocked.
You could also do this with jQuery's $.ajax
function, but I gravitate towards vanilla JavaScript.