// ==UserScript== // @name pp for osu score pages // @namespace http://osustats.ppy.sh // @description shows pp data from osustats.ppy.sh on osu score pages. // @include http*://osu.ppy.sh/b/* // @include http*://osu.ppy.sh/s/* // @include http*://osu.ppy.sh/p/beatmap?b=* // @include http*://osu.ppy.sh/p/beatmap?s=* // @grant GM_setValue // @grant GM_getValue // @grant GM_xmlhttpRequest // @version 3 // @downloadURL none // ==/UserScript== var result=null; var mapID=null; var mapMode=null; var scoresMissing=false; var time = 10; var interval; var requestedUpdate=false; function Start() { scoresMissing=false; if(mapID!=null && mapMode!=null) { GetScores(mapID,mapMode,function(res){ result = JSON.parse(res); UpdateOsuScoresTable(); if(scoresMissing && !requestedUpdate) { RequestBeatmapUpdate(mapID,mapMode,function(accepted){ if(accepted) { interval = setInterval(Countdown, 1000); } }); } else if(requestedUpdate) { SetInfoText("Updated successfully"); } }); } } function Init() { var mapTab = document.getElementsByClassName("beatmapTab active"); if(mapTab.length==1) { mapID = mapTab[0].href.split("/")[4]; mapID = mapID.split("&")[0]; mapMode = document.getElementsByClassName("active"); mapMode = mapMode[mapMode.length-1].href.split("&m=")[1]; } } function UpdateOsuScoresTable() { var rows,username,score,row,pp; rows = document.evaluate('//div[@class=\'beatmapListing\']/table/tbody/tr', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); rows.snapshotItem(0).children[5].innerHTML="Combo / pp"; for (var i=1;i/g,'').replace(/<\/b>/g,''); pp = GetPpFromUsername(username,score); console.log(requestedUpdate); if(requestedUpdate) { row.children[5].innerHTML = row.children[5].innerHTML.substring(0, row.children[5].innerHTML.indexOf('/')); } row.children[5].innerHTML += pp; } } function GetPpFromUsername(username,score) { for (var i=0;iUpdating in "+time+" seconds"); console.log(time); if(time == 0){ clearInterval(interval); SetInfoText("Updating..."); Start(); } } function SetInfoText(text) { rows = document.evaluate('//div[@class=\'content-with-bg\']/h2', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); row = rows.snapshotItem(0) row.previousElementSibling.innerHTML = "

"+text+"

"; } window.addEventListener('load', function() { Init(); Start(); }, false);