Greasy Fork

Greasy Fork is available in English.

mb. REVIVE DELETED EDITORS

musicbrainz.org: reveal deleted editors’ names and emphasizes your own name to standout in MB pages

当前为 2014-06-10 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         mb. REVIVE DELETED EDITORS
// @version      2014.0413.2044
// @description  musicbrainz.org: reveal deleted editors’ names and emphasizes your own name to standout in MB pages
// @namespace    https://github.com/jesus2099/konami-command
// @author       PATATE12 aka. jesus2099/shamo
// @licence      CC BY-NC-SA 3.0 (https://creativecommons.org/licenses/by-nc-sa/3.0/)
// @grant        none
// @include      http*://*musicbrainz.org/*edits*
// @include      http*://*musicbrainz.org/artist/*
// @include      http*://*musicbrainz.org/edit/*
// @include      http*://*musicbrainz.org/election*
// @include      http*://*musicbrainz.org/label/*
// @include      http*://*musicbrainz.org/recording/*
// @include      http*://*musicbrainz.org/release/*
// @include      http*://*musicbrainz.org/release-group/*
// @include      http*://*musicbrainz.org/search*type=editor*
// @include      http*://*musicbrainz.org/statistics/editors*
// @include      http*://*musicbrainz.org/user/*
// @include      http*://*musicbrainz.org/work/*
// @run-at       document-end
// ==/UserScript==
(function(){"use strict";
	/* - --- - --- - --- - START OF CONFIGURATION - --- - --- http://musicbrainz.org/user/Deleted%20Editor%20%2332978- --- - */
	var regrets = {
		 "Deleted Editor #32978": "tenebrous",         /*2003-12-13 - 2005-12-16*/
		 "Deleted Editor #93418": "Rhymeless",         /*2005-02-08 - 2013-03-05*/
		 "Deleted Editor #95678": "brianfreud",        /*2005-02-18 - 2012-09-24*/
		"Deleted Editor #129671": "Shlublu",           /*2005-06-30 - 2009-02-02*/
		"Deleted Editor #157767": "michael",           /*2005-10-20 - 2010-01-05*/
		"Deleted Editor #163497": "RedHotHeat",        /*2005-11-09 - 2012-07-12*/
		"Deleted Editor #186010": "robojock",          /*2005-12-30 - 2012-11-29*/
		"Deleted Editor #193948": "syserror",          /*2006-01-20 - 2008-01-27*/
		"Deleted Editor #240330": "theirfour",         /*2006-07-03 - 2012-11-27*/
		"Deleted Editor #313128": "mistoffeles",       /*2007-03-31 - 2009-02-06*/
		"Deleted Editor #346478": "neothe0ne",         /*2007-08-31 - 2011-05-28*/
		"Deleted Editor #386354": "grosnombril",       /*2008-03-04 - 2008-04-03*/
		"Deleted Editor #457889": "deivsonscherzinger",/*2009-04-12 - 2014-01-12*/
		"Deleted Editor #629372": "nightspirit",       /*2012-04-04 - 2014-04-08*/
		"Deleted Editor #701715": "remdia",            /*2013-01-07 - 2013-01-30*/
		"jesus2099": "GOLD MASTER KING",
		"%you%": "PROPHET PRINCE CHAMPION",
	};
	var mark /*of the life again*/ = "★";
	var standout /*from the crowd*/ = true;
	/* - --- - --- - --- - END OF CONFIGURATION - --- - --- - --- - */
	var MBS = self.location.protocol+"//"+self.location.host;
	var you = document.querySelector("div#header li.account a[href^='"+MBS+"/user/']");
	if (document.querySelector("div#header li.account a[href='"+MBS+"/logout'], div#page") == null) { return; }
	if (you) {
		if (regrets["%you%"]) {
			if (!regrets[you.textContent]) { regrets[you.textContent] = regrets["%you%"]; }
			delete regrets["%you%"];
		}
		if (standout) {
			var ys = document.querySelectorAll("div#page a[href='"+you.getAttribute("href")+"']");
			for (var y=0; y<ys.length; y++) {
				ys[y].style.setProperty("background-color", "yellow");
			}
		}
	}
	for (var user in regrets) { if (regrets.hasOwnProperty(user)) {
		var deled = user.match(/^deleted editor #[0-9]+$/i);
		document.title = deled?document.title.replace(new RegExp(user+"(”)?"), regrets[user]+"$1"+mark):document.title.replace(new RegExp("^Editor( “"+user+"”)"), regrets[user]+"$1");
		if (deled) {
			var as = document.querySelectorAll("a[href='"+MBS+"/user/"+escape(user)+"']");
			for (var a=0; a<as.length; a++) {
				for (var n=0; n<as[a].childNodes.length; n++) {
					if ((as[a].childNodes[n].nodeType == 3 || as[a].childNodes[n].tagName && as[a].childNodes[n].tagName == "BDI") && as[a].childNodes[n].textContent == user) {
						as[a].replaceChild(document.createTextNode(regrets[user]), as[a].childNodes[n]);
						as[a].style.setProperty("color", "darkred", "important");
						addAfter(document.createTextNode(mark), as[a]);
						as[a].setAttribute("title", user);
						as[a].className += "tooltip";
						break;
					}
				}
			}
		}
		if (self.location.href.match(new RegExp("^"+MBS+"/user/"+escape(user)+"$"))) {
			var dts = document.querySelectorAll("dl.profileinfo > dt");
			for (var dt=0; dt<dts.length; dt++) {
				if (dts[dt].textContent.match(/user type/i)) {
					var dd = getSibling(dts[dt], "dd");
					if (dd) {
						dd.setAttribute("title", dd.textContent.trim());
						removeChildren(dd);
						dd.appendChild(document.createTextNode(deled?user:regrets[user]));
						dd.style.setProperty("font-weight", "bold");
						dd.style.setProperty("text-shadow", "0 0 4px gold");
					}
					break;
				}
			}
		}
	} }
	if (localStorage && self.location.pathname == "/search" && self.location.search.match(/query=deleted.editor.type=editor/i) && document.querySelector("div#header-menu li.account a[href$='/user/jesus2099']")) {
		var lsmax = "jesus2099userjs152545debugmax";
		var max = localStorage.getItem(lsmax);
		max = max?parseInt(max, 10):0;max;
		var nmax = max;
		var editors = document.querySelectorAll("table a[href^='"+MBS+"/user/Deleted%20Editor%20%23']");
		for (var ed=0; ed<editors.length; ed++) {
			var id = editors[ed].getAttribute("href").match(/\d+$/);
			if (id > max) {
				if (id > nmax) { nmax = id; }
				editors[ed].style.setProperty("font-weight", "bold");
			}
		}
		if (nmax > max && confirm("store new max?")) { localStorage.setItem(lsmax, nmax); }
	}
	function removeChildren(p) {
		while (p && p.hasChildNodes()) { p.removeChild(p.firstChild); }
	}
	function getSibling(obj, tag, cls, prev) {
		var cur = obj;
		if (cur = prev?cur.previousSibling:cur.nextSibling) {
			if (cur.tagName == tag.toUpperCase() && (!cls || cls && cur.className.match(new RegExp("\\W*"+cls+"\\W*")))) {
				return cur;
			} else {
				return getSibling(cur, tag, cls, prev);
			}
		} else {
			return null;
		}
	}
	function addAfter(n, e) {
		if (n && e && e.parentNode) {
			if (e.nextSibling) { return e.parentNode.insertBefore(n, e.nextSibling); }
			else { return e.parentNode.appendChild(n); }
		} else { return null; }
	}
})();