Advertisement
SpyMomiji

綠色共產互聯網中介法審查創造安全和諧網路環境

Aug 18th, 2022
984
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         綠色共產互聯網中介法審查創造安全和諧網路環境
  3. // @namespace    https://www.plurk.com/SpyMomiji
  4. // @version      0.1
  5. // @description  將"此文章/討論串不存在或已被刪除" 替換成 "由於此訊息不符合國家網路中介法,已被屏蔽"
  6. // @author       SpyMomiji
  7. // @match        https://forum.gamer.com.tw/C.php?*
  8. // @match        https://forum.gamer.com.tw/Co.php?*
  9. // @grant        none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13.     'use strict';
  14.  
  15.     function busyPromise(waitFor,timeout=0){
  16.         return new Promise((a,b)=>{
  17.             var r,i,t;
  18.             if(Boolean(r=waitFor())){
  19.                 return a(r);
  20.             }
  21.             i = setInterval(function(){
  22.                 try{
  23.                     if(Boolean(r=waitFor())){
  24.                         clearInterval(i);
  25.                         clearTimeout(t);
  26.                         a(r);
  27.                     }
  28.                 } catch(e){
  29.                     clearInterval(i);
  30.                     clearTimeout(t);
  31.                     b(e)
  32.                 }
  33.             },1);
  34.             if(timeout) t = setTimeout(function(){
  35.                 clearInterval(i);
  36.                 try{a(waitFor())}
  37.                 catch(e){b(e)}
  38.             },timeout);
  39.         })
  40.     }
  41.  
  42.     function getTag(what, src = document.body){
  43.         return Array.from(src.getElementsByTagName(what));
  44.     }
  45.  
  46.     (async function(){
  47.         await busyPromise(()=>document.readyState=='complete',2000);
  48.  
  49.         if( getTag('title', document.head)[0].innerText
  50.            != '巴哈姆特電玩資訊站 - 系統訊息')
  51.             return;
  52.  
  53.         var dom =
  54.             getTag('div')
  55.         .filter( dom => dom.className == 'frame' )[0];
  56.  
  57.         dom =
  58.             getTag('p',dom)
  59.             .filter( d => d.innerText == '此文章/討論串不存在或已被刪除' )[0];
  60.  
  61.         dom.innerText = '由於此訊息不符合國家網路中介法,已被屏蔽';
  62.  
  63.     })()
  64. })();
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement