Instantly share code, notes, and snippets.
Last activeJanuary 25, 2025 04:20
Save NiceAesth/1ff313dc60bec626bceffecc9c509382 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
// ==UserScript== | |
//@name osuAvatarOpen | |
//@namespace https://aesth.dev/ | |
//@version 0.3 | |
//@updateURL https://gist.githubusercontent.com/NiceAesth/1ff313dc60bec626bceffecc9c509382/raw | |
//@downloadURL https://gist.githubusercontent.com/NiceAesth/1ff313dc60bec626bceffecc9c509382/raw | |
//@description Opens a user's osu! avatar on click | |
//@author NiceAesth | |
//@match https://osu.ppy.sh/users/* | |
//@icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
//@require https://gist.githubusercontent.com/NiceAesth/eec6a9fd695ea6c3574b21fe05b8aef8/raw | |
//@resource IMPORTED_CSS https://gist.githubusercontent.com/NiceAesth/e0c2378e2ef2b88e5d9c6d3547dcff0b/raw | |
//@grant GM_getResourceText | |
//@grant GM_addStyle | |
// ==/UserScript== | |
functiononModalClick(){ | |
varmodal=document.querySelector(".avatar-modal"); | |
modal.style.display="none"; | |
} | |
functiononAvatarClick(event){ | |
varavatarImg=event.target||event.srcElement; | |
varmodal=document.querySelector(".avatar-modal"); | |
varmodalImg=document.querySelector(".avatar-modal-content"); | |
varavatarImgStyle=avatarImg.currentStyle||window.getComputedStyle(avatarImg,false) | |
varavatarImgUrl=avatarImgStyle.backgroundImage.slice(4,-1).replace(/"/g,""); | |
modal.style.display="block"; | |
modalImg.src=avatarImgUrl; | |
} | |
functionloadListener(){ | |
varpage=document.querySelector(".osu-layout"); | |
varavatar=document.querySelector(".profile-info__avatar"); | |
// Ignore if on own profile | |
if(avatar.href){ | |
return; | |
} | |
varmodal=document.createElement("div"); | |
modal.setAttribute("class","avatar-modal"); | |
varmodalContent=document.createElement("img"); | |
modalContent.setAttribute("class","avatar-modal-content"); | |
modal.appendChild(modalContent); | |
page.appendChild(modal); | |
avatar.addEventListener("click",onAvatarClick); | |
modal.addEventListener("click",onModalClick); | |
} | |
waitForKeyElements(".profile-info__avatar",loadListener); | |
constcustomcss=GM_getResourceText("IMPORTED_CSS"); | |
console.log(GM_addStyle(customcss)); |
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment