Hide Chess.com Opponent Ratings

Hide ratings in games, and on your homepage. For those who don't want a constant reminder that their opponent is better (or worse) than them.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        Hide Chess.com Opponent Ratings
// @description Hide ratings in games, and on your homepage.  For those who don't want a constant reminder that their opponent is better (or worse) than them.
// @namespace   http://xyxyx.org/
// @include     http://www.chess.com/*
// @version     0.1
// @grant       none
// ==/UserScript==

try {

	var elements = document.getElementsByClassName("playerrating");
	if (elements) {
		for (var i = 0; i < elements.length; i++) {
			elements.item(i).style.visibility = 'hidden';
		}
	}

	var getElementByXpath = function (path) {
		return document.evaluate(path, document, null, 9, null).singleNodeValue;
	};

	var linkPrefix    =  "http://www.chess.com/members/view/";
	var linkPrefixLen = linkPrefix.length;
	var ratingPattern = / \([0-9]+\)/;

	elements = document.getElementById("mv-table-c16").getElementsByTagName("a");
	// console.log("Found " + elements.length);
	if (elements) {
		for (var i = 0; i < elements.length; i++) {
			var link = elements.item(i);
			//console.log("link = " + link);
			if (link && link.href.substring(0, linkPrefixLen) === linkPrefix) {
				var next = link.nextSibling;
				if (next && next.data) {
					//console.log("sibling " + link.href + ": " + next.data);
					if (ratingPattern.test(next.data)) {
						next.data = next.data.replace(ratingPattern, "");
					}
				}
			}
		}

	}

} catch(e) {
   console.log("Hide chess.com opponent ratings failed: " + e);
}