finkfad / ignore_user

// ==UserScript==
// @name	ignore_user
// @author finkfad
// @description	This script ignores all trolls, and their quoted replies in the HardwareZone forums. Original script was wholly contributed by forumer 'rowrife'.
// @include	https://forums.hardwarezone.com.sg/*
// @downloadURL https://openuserjs.org/install/finkfad/ignore_user.user.js
// @updateURL https://openuserjs.org/meta/finkfad/ignore_user.meta.js
// @version 1.0.4o
// @license MIT
// ==/UserScript==

function canIgnore(sUser) {
    var trolls = {
        "Abjure": undefined,
        "Yowe55": undefined,
		"ribena_berries": undefined,
		"radish": undefined,
		"paplumberwan": undefined,
		"NY__chickenpie": undefined,
		"Knight of Despair": undefined,
		"Bonadaly": undefined,
		"bemylove": undefined,
		"edmw_superman": undefined,
		"InnovaIQ": undefined,
		"angeltst": undefined,
		"Keverus": undefined,
		"emilyy": undefined,
		"Dr.Bonadaly": undefined,
		"stir ah stir": undefined,
		"twinkle07": undefined,
		"LightningStrikes": undefined,
		"hengheng96": undefined,
		"Wong K-Y": undefined,
		"654321": undefined,
		"Stupid Idiot": undefined,
		"Luckyboy86": undefined,
		"LazyBones": undefined,
		"Nitrile": undefined,
		"RJ45Cable": undefined,
		"Hiling care": undefined,
		"steven jialat": undefined,
		"jayjay07": undefined,
		"wMulew": undefined,
		"Ventide": undefined,
		"yeoyixin": undefined,
		"kitsura": undefined,
		"RadioAddict": undefined,
		"fox1": undefined,
		"Short_Time": undefined,
		"Ribbons_almark": undefined,
		"welli stewpig idiot": undefined,
		"sgt_hippo": undefined,
		"Singaporean1st": undefined,
		"michael_thm": undefined,
		"Nature Boy": undefined,
		"ProRick": undefined,
		"I<3PAP": undefined,
		"summersky1986": undefined,
		"nalide": undefined,
		"Luckyboy02": undefined,
		"Damn Stupid Wor": undefined,
		"smallbirdman": undefined,
		"mistersatki_": undefined,
		"WonderGirl": undefined,
		"onlinemoniter": undefined,
		"sAVaGEmP5": undefined,
		"TrueBlueSingaporean": undefined,
		"SiaoKau369": undefined,
		"Oppsuprlsr": undefined,
		"Poh Mata": undefined,
		"FriedBaconWong": undefined,
		"xiang887": undefined,
		"EDMW Psychiatrist": undefined,
		"bladehamster": undefined,
		"mikeoscar": undefined,
		"life_is_crazy": undefined,
		"Carnage": undefined,
		"PoYePoLuoMi": undefined,
		"ChinaCandy": undefined,
		"whitecolour": undefined,
		"cybercom8": undefined,
		"sxe_mytra": undefined,
		"ribenafish": undefined,
		"satki officer": undefined,
		"PoloBoiBoi": undefined,
		"widman01": undefined,
		"Tiongz": undefined,
		"whiterthanwhite": undefined,
		"machinery": undefined,
		"i ish hab a kwestion": undefined,
		"ahgong_tiger": undefined,
		"dunno88": undefined,
		"Abdul Rahman Bin Kassim": undefined,
		"Majulah": undefined,
		"behkan officer": undefined,
		"Rokusaburo": undefined,
		"Pigcanfly007": undefined,
		"misshanako": undefined,
		"cheesengboy": undefined,
		"pokkacoffee": undefined,
		"I_Love_PAP": undefined,
		"wujiandaosg": undefined,
		"A New Guy": undefined,
		"deathan9el": undefined,
		"bykte": undefined,
		"narcrollt": undefined,
		"Kumgong officer": undefined,
		"cheeko1234": undefined,
		"sinkiesongbo": undefined,
		"VanilaSky": undefined,
		"KiraX_19": undefined,
		"CAShop": undefined,
		"cran87": undefined,
		"ChinaCandy": undefined,
		"flower4s": undefined,
		"muddywaters": undefined,
		"Kumgong 0fficer": undefined,
		"pikafunk": undefined,
		"chiamingming": undefined,
		"cheeko4321": undefined,
		"typical_edmwer": undefined,
		"humanc0w": undefined,
		"Norman Osborn": undefined,
		"sleepy_person": undefined,
		"stir ah stir": undefined,
		"edmwclown": undefined,
		"_俏脸书生_": undefined,
		"Monster Boon": undefined,
		"[SG]Revolution": undefined,
		".狗男人女人.": undefined,
		"\*~内\*鬼~\*": undefined,
		"eatoofull": undefined,
		"celestite": undefined,
		"backsideitchy": undefined,
		"angelababy1": undefined,
		"born2win": undefined,
		"Stickerz": undefined,
		"honestedseller": undefined,
		"crimsontactics": undefined,
		"advrider": undefined,
		"cheowyonglee": undefined,
		"hoseiguy": undefined,
		"manutd887": undefined,
		"ImFromPipiForum": undefined,
		"AhBui168": undefined,
		"long_bird": undefined,
		"Patsfoo": undefined,
		"coltish": undefined,
		"thesealevel11": undefined,
		"whereismymill": undefined,
		"cheapeskate": undefined,
		"god_of_smallthings": undefined,
		"lovessammy": undefined,
		"chewbacca1": undefined,
		"prusswan.net": undefined,
		"Ferderico": undefined,
		"ashkrevron": undefined,
		"adrchi2000": undefined,
		"EveMuffins": undefined,
		"Jackygogogo": undefined,
		"sturrer": undefined,
		"vovolversace": undefined,
		"Magpir": undefined,
		"aromilk": undefined,
		"fapnoodles": undefined,
		"taogege": undefined,
		"derazor": undefined,
		"guayan": undefined,
		"TeenTitan01": undefined,
		"kamikazeben": undefined,
		"MoyoCase": undefined,
		"melonseed": undefined,
		"Whychiusostupid": undefined,
		"truefriend": undefined,
		"JM_LAU": undefined,
		"SMB388S": undefined,
		"smellypie": undefined,
		"Capitalist": undefined,
		"Zangief": undefined,
		"galatic": undefined,
		"kominato": undefined,
		"sweet_talker1": undefined,
		"hovivi": undefined,
		"megabyte14": undefined,
		"Strawberry_Cream": undefined,
		"Daimon": undefined,
		"ahboy82": undefined,
		"sgvideoman": undefined,
		"sevenoaks": undefined,
		"Dark84": undefined,
		"Ultrasofty": undefined,
		"bei_ge_wang": undefined,
		"jiiaying": undefined,
		"cloud24": undefined,
		"stanzza": undefined,
		"Jwee85": undefined,
		"Henry Ng": undefined,
		"therealsamhui": undefined,
		"soarer": undefined,
		"cheesepiejhj": undefined,
		"LouiseBrown": undefined,
		"Junnie": undefined,
		"longshooter": undefined,
		"satayxp": undefined,
		"relacker": undefined,
		"wisewise": undefined,
		"Fizzical": undefined,
		"buymyphone": undefined,
		"zzzzzzz.": undefined,
		"Beepok": undefined,
		"\[zhugeliang\]": undefined,
		"Harry Ng": undefined,
		"SaGu": undefined,
		"marigold": undefined,
		"zzzzzzz": undefined,
		"Fennel": undefined,
		"sevenpork": undefined,
		"raeboncheng": undefined,
		"scsim002": undefined,
		"johnsonheng": undefined,
		"eeLoyH": undefined,
		"John.D Rockefeller": undefined,
		"Jwee85": undefined,
		"FT PRIDE": undefined,
		"edwardthy": undefined,
		"Knight_Templar": undefined,
		"LONG LIVE FT": undefined,
		"VegetablePrince": undefined,
		"PlatiniumShrine": undefined,
		"cancer81": undefined,
		"blankk": undefined,
		"Nigho17": undefined,
		"StaLLbeRRies": undefined,
		"Intenerate": undefined,
		"gameacc": undefined,
		"Tommy Lee": undefined,
		"Alan Turing Reborn": undefined,
		"StunLike青青菜菜": undefined,
		"overman": undefined,
		"redcactus": undefined,
		"Quantum Entanglement": undefined,
		"rspcw1": undefined,
		"EVE.OP": undefined,
		"gtwace": undefined,
		"noiszuncle": undefined,
		"blurwulf": undefined,
		"Vanyel": undefined,
		"kingkongikiss": undefined,
		"Bunnyboy": undefined,
		"jayphus": undefined,
		"zzz2006": undefined,
		"sistarj": undefined,
		"ladiesman217": undefined,
		"icansing": undefined,
		"The Social Commentator": undefined,
		"bwaysaihump": undefined,
		"Minister": undefined,
		"IronMac": undefined,
		"romford": undefined,
		"fatty panda": undefined,
		"spiramirabilis": undefined,
		"eriolmoon2008": undefined,
		"chiohh": undefined,
		"palmero2009": undefined,
		"klarklar": undefined,
		"ramlee": undefined,
		"nyvrem": undefined,
		"Clintonian": undefined,
		"kheng86": undefined,
		"kosongice": undefined,
		"Agent Salt": undefined,
		"DanielsaN8": undefined,
		"Syllabus": undefined,
		"mummy1234": undefined,
		"[[ForeverAlone]]": undefined,
		"Roundtreex": undefined,
		"IndianChief": undefined,
		"jowter": undefined,
		"Worldsoul": undefined,
		"taker42": undefined,
		"Yureak": undefined,
		"neojudy": undefined,
		"bman75": undefined,
		"Denyius": undefined,
		"Dovahkiinskyrim": undefined,
		"Broadway": undefined,
		"Orionz": undefined,
		"axxomarketing": undefined,
		"jackycar": undefined,
		"relaxlabrudder": undefined,
		"PlayDough": undefined,
		"Broadwalk": undefined,
		"Are you good?": undefined,
		"MonsteR-Z": undefined,
		"santa_edmw": undefined,
		"BlackBus": undefined,
		"sayang_ol": undefined,
		"Mongoloid69": undefined,
		"Chisaki": undefined,
		"nubitol": undefined,
		"Angtehkor": undefined,
		"Polar Bear King": undefined,
    };
    
    if ( trolls.hasOwnProperty(sUser) ) {
        return true;
    }
    return false;
}

function getUserFromQuote(sHtml) {
	aM=sHtml.match(/<strong>(.+?)<\/strong>\s*wrote:\s*$/i);
	if(aM[1])
		return aM[1];
		
	return ''; //user not found
}

function setIgnoreThread() {
	var a; var s;
	
	a=document.evaluate(
	"//span[starts-with(@style, 'cursor:pointer')]",
	document,
	null,
	XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
	null);
	for (var i=0; i<a.snapshotLength; i++) {
		s=a.snapshotItem(i).innerHTML;
		if( canIgnore(s) ) {
			//a.snapshotItem(i).parentNode.parentNode.parentNode.style.display = 'none';
			a.snapshotItem(i).parentNode.parentNode.parentNode.innerHTML = '<td class="alt1"></td><td class="alt2"></td><td class="alt1"></td><td class="alt2"></td><td class="alt1"></td><td class="alt2"></td>';
		}
	}
}

function setIgnorePost() {
	var a; var s;
	
	a=document.evaluate(
	"//a[starts-with(@class, 'bigusername')]",
	document,
	null,
	XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
	null);
	for (var i=0; i<a.snapshotLength; i++) {
		s=a.snapshotItem(i).innerHTML;
		if( canIgnore(s) ) {
			//a.snapshotItem(i).parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.style.display = 'none';
			a.snapshotItem(i).parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.innerHTML = '<table width="100%"><tr><td class="thead">...</td></tr></table>';
		}
	}
}

function setIgnoreQuote() {
	var a; var s;
	
	a=document.evaluate(
	"//span[starts-with(@class, 'byline')]",
	document,
	null,
	XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
	null);
	for (var i=0; i<a.snapshotLength; i++) {
		s=getUserFromQuote( a.snapshotItem(i).innerHTML );
		if( s!='' && canIgnore(s) ) {
			//a.snapshotItem(i).parentNode.style.display = 'none';
			a.snapshotItem(i).parentNode.innerHTML = '';
		}
	}
}

if(window.opera) { //opera only
	(function(){
		document.addEventListener('DOMContentLoaded', function() {
			setIgnoreThread();
			setIgnorePost();
			setIgnoreQuote();
		}, false);
	})()
} else {
	setIgnoreThread();
	setIgnorePost();
	setIgnoreQuote();
}