From 3d940b73ba780e7e5a696936adc12df3c50d519e Mon Sep 17 00:00:00 2001 From: RayHammer Date: Sun, 23 Oct 2022 14:43:46 +0200 Subject: Added AdBlock bar script --- static/js/adblockbar.js | 67 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 static/js/adblockbar.js (limited to 'static/js') diff --git a/static/js/adblockbar.js b/static/js/adblockbar.js new file mode 100644 index 0000000..ee8031f --- /dev/null +++ b/static/js/adblockbar.js @@ -0,0 +1,67 @@ +/* + * Originally made by an anonymous netizen: https://adblockbar.neocities.org/ + * Modified by yours truly: https://rayhammer.dev/ + */ +var AdBlockBar = function() { + this.installed = true + this.displayOnce = true + + this.appUrls = { + "iPrison": "http://adblockios.com/", + "adSkynet5000": "https://adblockplus.org/", + "aRealComputer": "https://github.com/gorhill/uBlock" + } + + this.localStorageId = '__adblockbar_shown' + + if(navigator.userAgent.match(/(iPad|iPhone|iPod)/g)) + this.platform = 'iPrison' + else if(navigator.userAgent.match(/Android/i)) + this.platform = 'adSkynet5000' + else + this.platform = 'aRealComputer' + + this.detect = function() { + var bait = document.createElement('img') + bait.onerror = function() { + //this.parentNode.removeChild(this) + } + bait.id = '__adblockbar_bait' + bait.style['position'] = 'absolute' + bait.style['left'] = '-999em' + bait.src = 'ad1.jpg' + + document.getElementsByTagName('body')[0].insertBefore(bait, document.getElementsByTagName('body')[0].firstChild) + + var self = this + setTimeout(function() { + if(!bait || bait.style.display != 'none') + self.display() + }, 200) + } + + this.display = function() { + if(this.displayOnce === true && localStorage.getItem(this.localStorageId) == 'true') + return + + if(this.displayOnce === true) + localStorage.setItem(this.localStorageId, 'true') + + var html = '
⚠ Your browser is not using an ad blocker! This makes your browser slower and hurts your privacy. For the best web experience, you should install an ad blocker.
' + + var banner = document.createElement('div'); + banner.innerHTML = html; + this.banner = banner.firstChild + + var body = document.getElementsByTagName('body')[0] + body.insertBefore(this.banner, body.firstChild) + + //this.adjustPageMargin() + } + } + + window.onload = function() { + var adBlockBar = new AdBlockBar() + adBlockBar.displayOnce = false + adBlockBar.detect() + } \ No newline at end of file -- cgit v1.2.3