Skip to content

Instantly share code, notes, and snippets.

@0bach0
Created February 12, 2021 17:25
Show Gist options
  • Save 0bach0/f93bc0f2cb597e5bc2b7a6fc43692cd9 to your computer and use it in GitHub Desktop.
Save 0bach0/f93bc0f2cb597e5bc2b7a6fc43692cd9 to your computer and use it in GitHub Desktop.
For display an alert for remind user to help me run this page
// Need jQuery
// dataType and crossDomain for ignore CORS
// In case of loading adsbygoogle.js success, it still throw error related to the callback. That's why I only catch the 404 error
$.ajax({
type: "HEAD", url: "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js",
dataType: 'jsonp',
crossDomain: true,
success: function (data, text) {
// skip
},
error: function (request, status, error) {
if(request.status==404)
alert("Please disable adblock, it helps me running this blog :)");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment