JIRA Comment Censorship

Some people just aren't worth listening to.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           JIRA Comment Censorship
// @description   Some people just aren't worth listening to.
// @namespace      http://home.comcast.net/~mailerdaemon
// @include        http://jira.secondlife.com/*
// @version 0.0.1.20140517011140
// ==/UserScript==

const user_remove = [];
const user_collapse = ["Prokofy Neva"];
const user_purge = true; //remove mode: causes the elements to be deleted instead of simply hidden.
const before = "text()='";
const after = "'";
const scroll = true;//scroll to the target indicated after collapsing/deleting comments

GM_addStyle("div#issue_actions_container br{ line-height:0px;} div#issue_actions_container * br{ line-height:normal;}")
var count = 0;
var old_id;

if(user_purge)
{
	count += run(user_remove, remove);
	count += run(user_collapse, uh);
}
else
{
	count += run(user_collapse, uh);
	count += run(user_remove, hide);
}

if(scroll /*&& count > 0*/ && (path = /^#(.+)/.exec(decodeURIComponent( location.hash||'' ))))
{
	var node = $Y( "//a[@name='"+path[1]+"'] or //*[@id='"+path[1]+"']" );
	var x = unsafeWindow.scrollX;
	var y = unsafeWindow.scrollY;
	for(var i = 0;(link = node.snapshotItem(i)) && (x == unsafeWindow.scrollX) && (y == unsafeWindow.scrollY); i++)
		link.scrollIntoView();
}

//function GetNextSiblingNode(child, bad) {while((child = child.nextSibling) && child.nodeType == 3);return child?child:bad;}
function hide(target){	target.style.display="none"; }
function unhide(target){	target.style.display=""; }
function remove(target){	target.parentNode.removeChild(target); }
function $Y(_xpath, node){return document.evaluate(_xpath, node?node:document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);}

function uh(p, link)
{
	var id = p.id.substring(0,p.id.lastIndexOf("-"));
	if(old_id != id)
	{
		old_id = id;
		if((p.style.display == "none") != (p.id.indexOf("open")>=0))//no point in toggling it if it's already toggled.
			unsafeWindow.toggleDivsWithCookie(id+'-closed', id+'-open');
	}
}

function run(group, action)
{
	if(group.length > 0)
	{
		var res = $Y("//div[@class='action-details']/a["+before+group.join(after+" or "+before)+after+"]");
		var old_id;
		var i;
		for (i = 0; link = res.snapshotItem(i); ++i)
			action(link.parentNode.parentNode.parentNode, link);
		return i;
	}
}