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.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==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);
}