Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name 巴哈獲選者天天崩潰
- // @namespace https://www.plurk.com/SpyMomiji
- // @version 1.0c
- // @description 崩潰永遠跟隨獲選者。 強制換皮,單機版
- // @author SpyMomiji
- // @match https://home.gamer.com.tw/*
- // @match https://forum.gamer.com.tw/*
- // @icon https://www.google.com/s2/favicons?domain=gamer.com.tw
- // @grant none
- // @run-at document-body
- // ==/UserScript==
- (function() {
- 'use strict';
- let A2058_CRASH = "https://i.imgur.com/QAeDuWA.png";
- let UGLY = "https://avatar2.bahamut.com.tw/avataruserpic/a/2/a2058/a2058.png"
- //replace ugly-avatar let A2058 CRASH at home
- if(/https:\/\/home.gamer.com.tw\/.*.php\?.*(owner=A2058).*/i.test(location.href)){
- function letCrash(img){
- if(img.tagName != "IMG") return false;
- if(img.src == UGLY) img.src = A2058_CRASH;
- if(img.srcset == UGLY) img.srcset = A2058_CRASH;
- return true;
- }
- function foreach(collection, func){
- for(var i=0; i<collection.length; i++ )
- func(collection[i],i)
- }
- function busyWaiting(cat, todo){
- let intID = setInterval(function(){
- if(cat() || document.readyState=="complete"){
- clearInterval(intID);
- todo();
- }
- },1);
- }
- let rboxTraceStat = 0;
- let bhRboxDOM;
- busyWaiting(
- function(){
- let testDOM;
- switch(rboxTraceStat){
- case 0:
- testDOM = document.getElementsByClassName('BH-rbox MSG-list2');
- if(testDOM && testDOM[0]){
- rboxTraceStat = 1;
- bhRboxDOM = testDOM[0]
- }else return false;
- case 1:
- testDOM = bhRboxDOM.getElementsByTagName('img');
- if(testDOM){
- rboxTraceStat = 2;
- bhRboxDOM = testDOM
- }else return false;
- case 2:
- testDOM = false;
- foreach(bhRboxDOM, img => {
- if(img.className.match('MSG-myavatar')){
- testDOM |= letCrash(img);
- }
- })
- return testDOM;
- }
- return false;
- },
- function(){
- console.warn('小屋側邊崩潰成功');
- }
- )
- busyWaiting(
- function(){
- return Boolean(document.getElementById("BH-slave"))||
- Boolean(document.getElementById("BH-pagebtn"));
- },
- function(){
- let bhMaster = document.getElementById("BH-master");
- if(bhMaster){
- let searchArea = bhMaster.getElementsByClassName('HOME-mainbox1');
- foreach(searchArea, box =>{
- if(box.tagName != "DIV") return;
- try{
- foreach(box.getElementsByClassName('HOME-mainbox1a'), boxA =>{
- foreach(boxA.getElementsByTagName('img'), letCrash )
- })
- }
- catch(e){
- console.warn('小屋創作崩潰失敗');
- }
- })
- }
- }
- )
- }
- //inject CSS style let A2058 CRASH
- function mkEle(n,h){
- let e = document.createElement(n);
- e.innerHTML = h;
- return e;
- }
- document.head.append(mkEle('style',`
- div.tippy-tooltip-content .usercard a.usercard__avatar[href=https\\:\\/\\/home\\.gamer\\.com\\.tw\\/A2058],
- div.c-section__side a.gamercard[data-gamercard-userid=A2058] {
- background-image: url(${A2058_CRASH});
- background-size: contain;
- }
- div.tippy-tooltip-content .usercard a.usercard__avatar[href=https\\:\\/\\/home\\.gamer\\.com\\.tw\\/A2058] img,
- div.c-section__side a.gamercard[data-gamercard-userid=A2058] img {
- opacity: 0;
- }
- `
- ))
- console.log("崩潰了崩潰了")
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement