Skip to content

Instantly share code, notes, and snippets.

@Cr4zyy
Last active February 28, 2022 22:12
Show Gist options
  • Save Cr4zyy/2b54ea8b8ea42ae8a6cb96a9ced0f37e to your computer and use it in GitHub Desktop.
Save Cr4zyy/2b54ea8b8ea42ae8a6cb96a9ced0f37e to your computer and use it in GitHub Desktop.
cedapug.com queue mmr tampermonkey
// ==UserScript==
// @name cedapug.com queue mmr
// @namespace http://tampermonkey.net/
// @version 1.2
// @description show mmr next to player names in queue ffs
// @author Cr4zy
// @match https://cedapug.com/
// @icon https://www.google.com/s2/favicons?domain=cedapug.com
// @grant none
// ==/UserScript==
var playerMMR = [];
var updateInterval, updateIntervalNames = 10 //inital only loop updates time after this
//build array of player,mmr
setInterval(function(){
updateInterval = 30000 //get new array of names+mmr every 30s
let globalList = document.getElementById('globalChatUsers').getElementsByClassName('text-left');
playerMMR = [];
for (let l = 0; l < globalList.length; l++) {
let globalName = globalList[l].firstChild.innerText;
let globalMMR = globalList[l].lastChild.innerText;
let globalColor = "";
if (globalList[l].lastChild.children.length >= 1) {
globalColor = globalList[l].lastChild.children[0].className + ' rounded bg-dark pb-1 pl-2 pr-1 d-inline-flex';
} else if (globalList[l].lastChild.children.length <= 0) {
globalColor = "text-light rounded bg-dark pb-1 pl-2 pr-1 d-inline-flex";
}
if ( globalName === globalMMR ) {
globalMMR = '⚠ UNRATED!';
}
//queue list limits names to 10 chars so cut for compare
let nameLength = 10;
globalName = globalName.substring(0, nameLength).replace(/ +$/, '');
globalMMR = globalMMR.replace(/[\[\]']+/g, ''); //remove []
globalMMR = '<span class="' + globalColor + '">' + globalMMR + '&nbsp;</span> </strong>' //idk some garbage mess
playerMMR.push([globalName,globalMMR]);
}
},updateInterval);
setInterval(function(){
updateInterval = 1000 // update queue names every second
for (let q = 0; q < 3; q++){
let qskill = q+1
let queue = document.getElementById('queueList_'+qskill);
let playerList = queue.getElementsByClassName('col-7');
for (let i = 0; i < playerList.length; i++) {
let playerName = (playerList[i].innerText);
for (let p = 0; p < playerMMR.length; p++) {
if( playerMMR[p][0] === playerName ) {
let result = playerMMR[p];
playerList[i].innerHTML = '<strong>' + playerMMR[p];
break;
}
}
}
}
}, updateIntervalNames);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment