osu! pp for Scoreboard [Offline Ver.]

a remake of https://greasyfork.org/en/scripts/3280-osu-pp-for-scoreboard (osu! pp for Scoreboard)

  1. // ==UserScript==
  2. // @name osu! pp for Scoreboard [Offline Ver.]
  3. // @namespace http://wa.vg/
  4. // @author JebwizOscar
  5. // @icon http://osu.ppy.sh/favicon.ico
  6. // @include http://osu.ppy.sh/b/*
  7. // @include https://osu.ppy.sh/b/*
  8. // @include http://osu.ppy.sh/s/*
  9. // @include https://osu.ppy.sh/s/*
  10. // @include http://osu.ppy.sh/p/beatmap?*
  11. // @include https://osu.ppy.sh/p/beatmap?*
  12. // @include https://osu.ppy.sh/p/api
  13. // @include http://osu.ppy.sh/p/api
  14. // @grant GM_getValue
  15. // @grant GM_setValue
  16. // @grant GM_deleteValue
  17. // @copyright 2016, ieb
  18. // @version 16.07.23.3
  19. // @namespace https://greasyfork.org/users/3079
  20. // @require https://code.jquery.com/jquery-1.8.3.min.js
  21. // @description a remake of https://greasyfork.org/en/scripts/3280-osu-pp-for-scoreboard (osu! pp for Scoreboard)
  22. // ==/UserScript==
  23. key = GM_getValue("osu-api-key", "none");
  24. url = document.location.href;
  25.  
  26. if (~url.indexOf('/api')) {
  27. if (typeof ($($('.feedback div')[2]).text().split(' ')[2]) !== 'undefined') {
  28. key = $($('.feedback div')[2]).text().split(' ')[2];
  29. GM_setValue("osu-api-key", key);
  30. alert("New Key Updated: " + key);
  31. }
  32. } else {
  33. if (key !== "none") {
  34. endpoint = '/api/get_scores?k='+key;
  35. suf = $('.beatmapTab.active').attr("href").replace('/b/','&b=');
  36. mode = $('.beatmapTab.active').attr("href").replace(/.*&m=(\d+)/,'$1');
  37. leader = $($($('.scoreLeader')[0]).children(0).children(0).children(0).children(0)[1]).attr("href").replace('/u/','&u=');
  38. $.get(endpoint+suf+leader, {}, function(data) {
  39. for(var i in data){
  40. $($('.scoreLeader')[0]).children(0).append('<tr class="row2p"><td><strong>pp</strong></td><td>'+data[i].pp+' pp</td><td></td></tr>');
  41. }
  42. });
  43. if (typeof localUserId !== "undefined") {
  44. me = '&u=' + localUserId;
  45. if ($('.scoreLeader').size()==2){
  46. $.get(endpoint+suf+me, {}, function(data) {
  47. for(var i in data){
  48. $($('.scoreLeader')[1]).children(0).append('<tr class="row2p"><td><strong>pp</strong></td><td>'+data[i].pp+' pp</td><td></td></tr>');
  49. }
  50. });
  51. }
  52. }
  53. $.get(endpoint+suf, {}, function(data) {
  54. for(var i in data){
  55. if (mode==3) $('[href="/u/'+data[i].user_id+'"]').last().parent().parent().append('<td></td>');
  56. $('[href="/u/'+data[i].user_id+'"]').last().parent().parent().append('<td>'+data[i].pp+'</td>');
  57. }
  58. });
  59. $('.titlerow').append('<th><strong>pp</strong></th>');
  60. unsafeWindow.delKey = function(){
  61. GM_deleteValue("osu-api-key");
  62. window.location.reload();
  63. };
  64. $('[name=scores]').after('<a href="/p/api"><strong>Current API Key: '+key.substr(0,8)+'</strong></a> &middot; <a onclick="delKey()"><strong>[remove]</strong></a>');
  65. } else {
  66. $('[name=scores]').after('<a href="/p/api"><strong>Get your API key for pp script here</strong></a>');
  67. }
  68. }