Skip to content

Instantly share code, notes, and snippets.

@rigwild
Last active August 3, 2022 17:23
Show Gist options
  • Save rigwild/7ec5af7ae40792978946502c91ca726f to your computer and use it in GitHub Desktop.
Save rigwild/7ec5af7ae40792978946502c91ca726f to your computer and use it in GitHub Desktop.
Show Anons S2 ranks on Stashh
// ==UserScript==
// @name Show Anons S2 ranks
// @namespace Violentmonkey Scripts
// @version 0.1
// @description Show Anons S2 ranks on Stashh
// @author rigwild
// @match https://stashh.io/*
// @icon https://www.google.com/s2/favicons?domain=stashh.io
// @grant none
// ==/UserScript==
(async function() {
'use strict';
const myRarity = await fetch('https://anons-s2-ranks.rigwild.workers.dev/').then(res => res.json()).then(res => res._output_rarity.elements)
if (typeof window.ranksShown !== 'boolean') window.ranksShown = false
function showRanksVisibleMessage() {
if (!window.ranksShown) {
const showingRanks = document.createElement('div')
showingRanks.innerText = 'Showing ranks (Anons S2)'
showingRanks.style.color = 'red'
showingRanks.style.position = 'sticky'
showingRanks.style.fontWeight = 'bold'
showingRanks.style.fontSize = '20px'
showingRanks.style.textAlign = 'center'
showingRanks.style.top = '20px'
showingRanks.style.left = '-200px'
showingRanks.style.width = '100%'
showingRanks.style.zIndex = 9999
document.body.prepend(showingRanks)
window.ranksShown = true
}
}
function showRanks() {
let visibleTitles = [...document.querySelectorAll('.css-1ogcd12'), ...document.querySelectorAll('.css-qj2xh2')]
visibleTitles.forEach(title => {
title.style.overflow = 'inherit'
const match = title.innerText.match(/^Anon Army #(\d+)$/)
if (match && match.length >= 2) {
const id = +match[1]
let change = myRarity[id].rank - myRarity[id].rankWithoutTraitsCount
change = change >= 0 ? `⬇️${change}` : `⬆️${Math.abs(change)}`
title.innerText = `${id} | 🏆 ${myRarity[id].rankWithoutTraitsCount} > ${myRarity[id].rank} (${change})`
showRanksVisibleMessage()
}
})
}
setInterval(showRanks, 500)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment