mcbbs_avatar

MCBBS头衔显示修复

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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 https://greasyfork.org/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);