// ==UserScript== // @name 网页屏蔽器 test // @version 1.2.0 // @description 屏蔽整个网站 // @namespace PPPScript // @license MIT // @author PPP // @include * // @run-at document-start // @grant unsafeWindow // @grant GM_setValue // @grant GM_getValue // @downloadURL none // ==/UserScript== var PPPbanner = Object.assign(PPPbanner || {}, {top: 0, left: 0}); let hre = window.location.origin; (function() { let orig = GM_getValue("PPP_banner_bannedlist"); if(localStorage.PPP_banned_sign == 'true') GM_setValue("PPP_banner_bannedlist", (typeof orig == 'object' ? (orig[hre] = null, orig) : (orig = {}, orig[hre] = null, orig))); console.log("PPP 创作的 网页屏蔽器 屏蔽名单:", orig); })(); (function() { let orig = GM_getValue("PPP_banner_whitelist"); if(localStorage.PPP_unbanned_sign == 'true') GM_setValue("PPP_banner_whitelist", (typeof orig == 'object' ? (orig[hre] = null, orig) : (orig = {}, orig[hre] = null, orig))); console.log("PPP 创作的 网页屏蔽器 白名单:", orig); })(); if(localStorage.PPP_unbanned_sign != 'true') { if(localStorage.PPP_banned_sign == 'true') { let innerHtml = ` 此网站已被屏蔽 取消屏蔽

此网站已被屏蔽


来自 PPP 创作的 网页屏蔽器。

`; console.log(`PPP 创作的 网页屏蔽器 已自动屏蔽该网站:${window.location.origin}`); let last = 1, now, iself, countChange = -1, first = true, dangerLevels = [1000000, 100000, 10000, 3000, 1250, 500, 200, 100, 50, 25, 10, 5, 2, 1]; for(let i = now = setInterval(function() {}, 1); i > last; i--) clearInterval(i), clearTimeout(i); last = now; iself = setInterval(function() { if(document.documentElement.innerHTML != innerHtml) { for(let i = now = setInterval(function() {}, 1); i > last; i--) if(i != iself) clearInterval(i), clearTimeout(i); last = now, countChange++, document.documentElement.innerHTML = innerHtml; if(countChange >= dangerLevels[dangerLevels.length - 1]) console.error(`请确认你的其他脚本没有问题。对抗次数已经达到 ${dangerLevels.pop()} 次。`); document.querySelector('PPP-banner > PPP-banner-button:last-child').onclick = function() { if(confirm(`您确定要取消屏蔽该网站吗?(${hre})`) === true) { let orig = GM_getValue("PPP_banner_bannedlist"); GM_setValue("PPP_banner_bannedlist", typeof orig == 'object' ? (delete orig[hre], orig) : {}); delete localStorage.PPP_banned_sign; window.location.reload(); } }; if(first) innerHtml = document.documentElement.innerHTML, first = false; } }, 16); } else { let innerHtml = ` 屏蔽该网站 隐藏 `; console.log(`PPP 创作的 网页屏蔽器 已开启`); setInterval(function() { if(document.querySelector('PPP-banner') == null) { document.body.insertAdjacentHTML("beforeend", innerHtml); document.documentElement.ondragover = function(event) { event.preventDefault(); }; document.body.querySelector('PPP-banner-dragger').ondragstart = function(event) { // if(event.x !== undefined) // console.dir(event); PPPbanner.top = event.clientY - document.querySelector('PPP-banner').style.top.substr(0, document.querySelector('PPP-banner').style.top.length - 2); PPPbanner.left = event.clientX - document.querySelector('PPP-banner').style.left.substr(0, document.querySelector('PPP-banner').style.left.length - 2); }; document.body.querySelector('PPP-banner-dragger').ondragend = function(event) { document.querySelector('PPP-banner').style.top = Math.min(Math.max(0, localStorage.PPP_banner_lasttop = event.clientY - PPPbanner.top), window.innerHeight - document.body.querySelector('PPP-banner').getBoundingClientRect().height) + 'px'; document.querySelector('PPP-banner').style.left = Math.min(Math.max(0, localStorage.PPP_banner_lastleft = event.clientX - PPPbanner.left), window.innerWidth - document.body.querySelector('PPP-banner').getBoundingClientRect().width) + 'px'; }; document.querySelector('PPP-banner > PPP-banner-button:not(PPP-banner > PPP-banner-button:last-child)').onclick = function(event) { if(confirm(`您确定要屏蔽该网站吗?(${hre})`) === true) { localStorage.PPP_banned_sign = 'true'; let orig = GM_getValue("PPP_banner_bannedlist"); GM_setValue("PPP_banner_bannedlist", typeof orig == 'object' ? (orig[hre]= null, orig) : (orig = {}, orig[hre]= null, orig)); window.location.reload(); } }; document.querySelector('PPP-banner > PPP-banner-button:last-child').onclick = function(event) { if(confirm(`您确定要取消此按钮吗?(在 ${hre})`) === true) { if(confirm(`要永久隐藏吗?(否则本次会话会隐藏)`) == true) { localStorage.PPP_unbanned_sign = 'true'; let orig = GM_getValue("PPP_banner_whitelist"); GM_setValue("PPP_banner_whitelist", typeof orig == 'object' ? (orig[hre]= null, orig) : (orig = {}, orig[hre]= null, orig)); } document.querySelector('PPP-banner').style.display = 'none'; } }; setInterval(function() { document.querySelector('PPP-banner').style.top = Math.min(Math.max(0, localStorage.PPP_banner_lasttop), window.innerHeight - document.body.querySelector('PPP-banner').getBoundingClientRect().height) + 'px'; document.querySelector('PPP-banner').style.left = Math.min(Math.max(0, localStorage.PPP_banner_lastleft), window.innerWidth - document.body.querySelector('PPP-banner').getBoundingClientRect().width) + 'px'; }, 16); } }, 16); } } if(!(localStorage.PPP_unbanned_sign != 'true' && localStorage.PPP_banned_sign == 'true')) { let styles = document.createElement('style'); styles.innerText = `a[href][PPP-banned] { filter: sepia(1); }`; document.head.appendChild(styles); setInterval(function() { let orig = GM_getValue('PPP_banner_bannedlist'), alist = [...document.querySelectorAll('a[href]:not(a[href][PPP-checked])')]; for(let i = 0; i < alist.length; i++) { if(orig[new URL(alist[i].getAttribute('href'), window.location.href).origin] !== undefined) alist[i].setAttribute('PPP-banned', ''), alist[i].setAttribute('title', "你屏蔽了它:" + new URL(alist[i].getAttribute('href'), window.location.href).origin + ",对吧?\n\n来自由 PPP 创作的 网页屏蔽器。"); else alist[i].setAttribute('PPP-checked', ''); } }, 16); }