Greasy Fork

Greasy Fork is available in English.

mcbbs_avatar

MCBBS头衔显示修复

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           mcbbs_avatar
// @description    MCBBS头衔显示修复
// @author         浅念
// @version        1.1
// @include        http*://mcbbs.tvt.im/*
// @include        http*://mcbbs.net/*
// @grant          none
// @namespace http://greasyfork.icu/zh-CN/scripts/29047-mcbbs-avatar
// ==/UserScript==

var html=document.getElementsByTagName("img");
for(var i=0;i<html.length;i++){
 if(html[i].src.indexOf("http://www.mcbbs.net/uc_server/avatar.php")>-1){
	 html[i].src=html[i].src.replace(/www.mcbbs.net/g, "mcbbs.tvt.im");
 }
}
var s = document.createElement("script");
s.innerHTML='\
function modifyResponse(response) {\
	var html=document.getElementsByTagName("img");\
	for(var i=0;i<html.length;i++){\
	 if(html[i].src.indexOf("http://www.mcbbs.net/uc_server/avatar.php")>-1){\
		 html[i].src=html[i].src.replace(/www.mcbbs.net/g, "mcbbs.tvt.im");\
	 }\
	}\
\
}\
\
function openBypass(original_function) {\
\
    return function(method, url, async) {\
        this.requestMethod = method;\
        this.requestURL = url;\
\
        this.addEventListener("readystatechange", modifyResponse);\
        return original_function.apply(this, arguments);\
    };\
\
}\
\
function sendBypass(original_function) {\
    return function(data) {\
        this.requestData = data;\
        return original_function.apply(this, arguments);\
    };\
}\
\
XMLHttpRequest.prototype.open = openBypass(XMLHttpRequest.prototype.open);\
XMLHttpRequest.prototype.send = sendBypass(XMLHttpRequest.prototype.send);\
';
s.onload = function() {
    this.remove();
};
(document.head || document.documentElement).appendChild(s);