Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Blockadblock: Difference between revisions

Template page
No edit summary
No edit summary
Line 1: Line 1:
<html>
<html>
<script type="text/javascript">
<script type="text/javascript">
/**
function detectAdblock(){const adblockTests={uBlockOrigin:{url:"https://incolumitas.com/data/pp34.js?sv=",id:"837jlaBksSjd9jh"},adblockPlus:{url:"https://incolumitas.com/data/neutral.js?&ad_height=",id:"hfuBadsf3hFAk"}};function canLoadRemoteScript(obj){return new Promise(function(resolve,reject){var script=document.createElement("script");script.onload=function(){if(document.getElementById(obj.id)){resolve(false)}else{resolve(true)}};script.onerror=function(){resolve(true)};script.src=obj.url;document.body.appendChild(script)})}return new Promise(function(resolve,reject){let promises=[canLoadRemoteScript(adblockTests.uBlockOrigin),canLoadRemoteScript(adblockTests.adblockPlus)];Promise.all(promises).then(results=>{resolve({uBlockOrigin:results[0],adblockPlus:results[1]})}).catch(err=>{reject(err)})})}
* Author: Nikolai Tschacher
* Updated: 16.08.2022
* Website: https://incolumitas.com/
*
* Detect uBlock Origin, Adblock Plus and Ghostery with JavaScript only
*
* Usage: detectAdblock().then((res) => { console.log(res) });
*
*/
function detectAdblock() {
  const adblockTests = {
    // https://github.com/uBlockOrigin/uAssets/blob/master/filters/filters-2022.txt
    uBlockOrigin: {
      url: 'https://incolumitas.com/data/pp34.js?sv=',
      id: '837jlaBksSjd9jh',
    },
    // https://github.com/easylist/easylist/blob/master/easylist/easylist_general_block.txt
    adblockPlus: {
      url: 'https://incolumitas.com/data/neutral.js?&ad_height=',
      id: 'hfuBadsf3hFAk',
    },
  };
 
  function canLoadRemoteScript(obj) {
    return new Promise(function (resolve, reject) {
      var script = document.createElement('script');
 
      script.onload = function () {
        if (document.getElementById(obj.id)) {
          resolve(false);
        } else {
          resolve(true);
        }
      }
 
      script.onerror = function () {
        resolve(true);
      }
 
      script.src = obj.url;
      document.body.appendChild(script);
    });
  }
 
  return new Promise(function (resolve, reject) {
    let promises = [
      canLoadRemoteScript(adblockTests.uBlockOrigin),
      canLoadRemoteScript(adblockTests.adblockPlus),
    ];
 
    Promise.all(promises).then((results) => {
      resolve({
        uBlockOrigin: results[0],
        adblockPlus: results[1],
      });
    }).catch((err) => {
      reject(err);
    });
  });
}
 
detectAdblock().then((res) => {
  var ublockEl = document.getElementById('ublock_origin');
  var adblockEl = document.getElementById('adblock_plus');
 
  if (res.uBlockOrigin) {
    ublockEl.innerHTML = 'You are using uBlock Origin! (' + res.uBlockOrigin + ')';
  } else {
    ublockEl.style.backgroundColor = '#63ff85';
    ublockEl.innerHTML = 'You are not using uBlock Origin (' + res.uBlockOrigin + ')';
  }
 
  if (res.adblockPlus) {
    adblockEl.innerHTML = 'You are using Adblock Plus! (' + res.adblockPlus + ')';
  } else {
    adblockEl.style.backgroundColor = '#63ff85';
    adblockEl.innerHTML = 'You are not using Adblock Plus (' + res.adblockPlus + ')';
  }
});
</script>
</script>
   <script type="text/javascript">
   <script type="text/javascript">

Revision as of 02:16, 6 October 2022

Advertising: