Enhanced rankings at goratings.org -Update: Added Age column
Posted: Fri Mar 18, 2022 9:35 am
by Toukopouko
Hey,
I made a small script that adds gender and country/region filters to goratings.org.

How to use in Chrome Browser?
Please note! An updated version of the script is in post #4
1. Add a new bookmark in Chrome (Right click the bookmark bar and select "Add Page..."). Add a name (for example "Enhance Ratings").
2. Copy-paste the following script to the URL part of the bookmark. Save.
3. Navigate to https://www.goratings.org/en/. Click the bookmark you saved. Voila!
Full Code
Here is an easier-to-read version of the code (without the javascript: prefix). Feel free to inspect or improve, but please share with everyone if you make something cool
Please Note! Always be cautious when you copy-paste scripts from online!
I made a small script that adds gender and country/region filters to goratings.org.

How to use in Chrome Browser?
Please note! An updated version of the script is in post #4
1. Add a new bookmark in Chrome (Right click the bookmark bar and select "Add Page..."). Add a name (for example "Enhance Ratings").
2. Copy-paste the following script to the URL part of the bookmark. Save.
Code: Select all
javascript:function fn(){ tables = Array.from(document.getElementsByTagName("tbody")); rankingTable = tables.at(-1); rankingTableRows = Array.from(rankingTable.children); if (rankingTableRows[0].children.length > 5) { console.log("Already initialized.."); } else { console.log("Initializing the enhanced rankings.."); gender = "all"; flag = "all"; function updateTable() { rank = 1; rankingTableRows.slice(1).forEach(el => { elGender = el.children[3]?.children[0]?.textContent === "♂" ? "men" : "women"; elFlag = el.children[4]?.children[0]?.alt; if (!['cn', 'jp', 'kr', 'tw'].includes(elFlag)) { elFlag = "other"; } if ((gender === "all" || elGender === gender) && (flag == "all" || elFlag === flag)) { el.children[0].textContent = rank++; el.style.display = "table-row"; } else { el.style.display = "none"; } }); } function createGenderSelect(parentEl) { const genderSelect = document.createElement("SELECT"); genderSelect.setAttribute("id", "genderSelect"); const all = document.createElement("option"); const men = document.createElement("option"); const women = document.createElement("option"); all.setAttribute("value", "all"); men.setAttribute("value", "men"); women.setAttribute("value", "women"); all.textContent = "All"; men.textContent = "Men"; women.textContent = "Women"; genderSelect.append(all, men, women); genderSelect.onchange = function(event){gender = event.target.value; updateTable();}; parentEl.setAttribute('style', 'white-space: pre;'); parentEl.textContent = "Gender\r\n"; parentEl.appendChild(genderSelect); } function createFlagSelect(parentEl) { const flagSelect = document.createElement("SELECT"); flagSelect.setAttribute("id", "flagSelect"); const all = document.createElement("option"); const china = document.createElement("option"); const japan = document.createElement("option"); const korea = document.createElement("option"); const taiwan = document.createElement("option"); const other = document.createElement("option"); all.setAttribute("value", "all"); china.setAttribute("value", "cn"); japan.setAttribute("value", "jp"); korea.setAttribute("value", "kr"); taiwan.setAttribute("value", "tw"); other.setAttribute("value", "other"); all.textContent = "All"; china.textContent = "China"; japan.textContent = "Japan"; korea.textContent = "Korea"; taiwan.textContent = "Taiwan"; other.textContent = "Other"; flagSelect.append(all, china, japan, korea, taiwan, other); flagSelect.onchange = function(event){flag = event.target.value; updateTable();}; parentEl.setAttribute('style', 'white-space: pre;'); parentEl.textContent = "Flag\r\n"; parentEl.appendChild(flagSelect); } header = rankingTableRows[0]; headerRow = header.children; headerRow[0].setAttribute('style', 'white-space: pre;'); headerRow[0].textContent = "Overall\r\nRank"; createGenderSelect(headerRow[2]); createFlagSelect(headerRow[3]); newRank = headerRow[0].cloneNode(); newRank.textContent = "Rank"; header.prepend(newRank); rank = 1; rankingTableRows.slice(1).forEach(el => { copyEl = el.children[0].cloneNode(); copyEl.textContent = rank++; el.prepend(copyEl); }); } } fn();Full Code
Here is an easier-to-read version of the code (without the javascript: prefix). Feel free to inspect or improve, but please share with everyone if you make something cool
Code: Select all
function fn(){
tables = Array.from(document.getElementsByTagName("tbody"));
rankingTable = tables.at(-1);
rankingTableRows = Array.from(rankingTable.children);
if (rankingTableRows[0].children.length > 5) {
console.log("Already initialized..");
} else {
console.log("Initializing the enhanced rankings..");
gender = "all";
flag = "all";
function updateTable() {
rank = 1;
rankingTableRows.slice(1).forEach(el => {
elGender = el.children[3]?.children[0]?.textContent === "♂" ? "men" : "women";
elFlag = el.children[4]?.children[0]?.alt;
if (!['cn', 'jp', 'kr', 'tw'].includes(elFlag)) {
elFlag = "other";
}
if ((gender === "all" || elGender === gender) &&
(flag == "all" || elFlag === flag)) {
el.children[0].textContent = rank++;
el.style.display = "table-row";
} else {
el.style.display = "none";
}
});
}
function createGenderSelect(parentEl) {
const genderSelect = document.createElement("SELECT");
genderSelect.setAttribute("id", "genderSelect");
const all = document.createElement("option");
const men = document.createElement("option");
const women = document.createElement("option");
all.setAttribute("value", "all");
men.setAttribute("value", "men");
women.setAttribute("value", "women");
all.textContent = "All";
men.textContent = "Men";
women.textContent = "Women";
genderSelect.append(all, men, women);
genderSelect.onchange = function(event){gender = event.target.value; updateTable();};
parentEl.setAttribute('style', 'white-space: pre;');
parentEl.textContent = "Gender\r\n";
parentEl.appendChild(genderSelect);
}
function createFlagSelect(parentEl) {
const flagSelect = document.createElement("SELECT");
flagSelect.setAttribute("id", "flagSelect");
const all = document.createElement("option");
const china = document.createElement("option");
const japan = document.createElement("option");
const korea = document.createElement("option");
const taiwan = document.createElement("option");
const other = document.createElement("option");
all.setAttribute("value", "all");
china.setAttribute("value", "cn");
japan.setAttribute("value", "jp");
korea.setAttribute("value", "kr");
taiwan.setAttribute("value", "tw");
other.setAttribute("value", "other");
all.textContent = "All";
china.textContent = "China";
japan.textContent = "Japan";
korea.textContent = "Korea";
taiwan.textContent = "Taiwan";
other.textContent = "Other";
flagSelect.append(all, china, japan, korea, taiwan, other);
flagSelect.onchange = function(event){flag = event.target.value; updateTable();};
parentEl.setAttribute('style', 'white-space: pre;');
parentEl.textContent = "Flag\r\n";
parentEl.appendChild(flagSelect);
}
header = rankingTableRows[0];
headerRow = header.children;
headerRow[0].setAttribute('style', 'white-space: pre;');
headerRow[0].textContent = "Overall\r\nRank";
createGenderSelect(headerRow[2]);
createFlagSelect(headerRow[3]);
newRank = headerRow[0].cloneNode();
newRank.textContent = "Rank";
header.prepend(newRank);
rank = 1;
rankingTableRows.slice(1).forEach(el => {
copyEl = el.children[0].cloneNode();
copyEl.textContent = rank++;
el.prepend(copyEl);
});
}
}
fn();