Show Rocket League Stats via Steam

Create a link in a user's steam profile to quickly see his stats Rocket League.

  1. // ==UserScript==
  2. // @name Show Rocket League Stats via Steam
  3. // @namespace steam
  4. // @include /https?:\/\/steamcommunity\.com\/(id|profiles)\/[^/]+\/?$/
  5. // @description Create a link in a user's steam profile to quickly see his stats Rocket League.
  6. // @version 1.2
  7. // @author @Glaived_Dev
  8. // @licence CC0 - Public Domain
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. /**
  13. * @namespace
  14. * @property {object} config
  15. * @property {object} config.variables - Contains script configuration.
  16. * @property {string} config.variables.siteForShowStats - Site used to display statistics. "rocketleague.tracker.network" | "rocketleaguestats"
  17. * @property {bool} config.variables.sameTab - If you want open the page in the same tab
  18. */
  19. config = function(){
  20. var variables = {
  21. siteForShowStats: "rocketleague.tracker.network",
  22. sameTab: true,
  23. };
  24.  
  25. function init(){};
  26.  
  27. return {
  28. init: init,
  29. variables: variables,
  30. };
  31. }();
  32.  
  33. /*******************************************************************************************************************************************************
  34. *******************************************************************************************************************************************************
  35. **************************** ****************************
  36. **************************** DON'T MODIFY ANYTHING BELOW ****************************
  37. **************************** ****************************
  38. *******************************************************************************************************************************************************
  39. *******************************************************************************************************************************************************
  40. */
  41.  
  42. id = window.location.href.replace(new RegExp(/https?:\/\/steamcommunity\.com\/(id|profiles)\//), "");
  43.  
  44. if(id.substr(id.length - 1) == "/") id = id.slice(0, -1);
  45.  
  46. jQuery(document).ready(function(){
  47. console.log("%c INFO : Show Rocket League Stats via Steam script is running… ", "color: #3498db");
  48.  
  49. if(config.variables.siteForShowStats == "rocketleaguestats")
  50. var url = "https://rocketleaguestats.com/profile/steam/";
  51. else if(config.variables.siteForShowStats == "rocketleague.tracker.network")
  52. var url = "https://rocketleague.tracker.network/profile/steam/";
  53. else
  54. var url = "https://rocketleague.tracker.network/profile/steam/";
  55.  
  56. var tab = config.variables.sameTab ? "_self" : "_blank";
  57. var private = jQuery(".profile_private_info").size() > 0 ? true : false;
  58.  
  59. if(private){
  60. jQuery("head").append("<style>\
  61. .profile_header_actions {\
  62. clear: both;\
  63. }\
  64. .profile_header_badgeinfo_badge_area {\
  65. float: right;\
  66. }\
  67. .profile_header .profile_header_centered_persona {\
  68. right: initial;\
  69. }\
  70. </style>");
  71.  
  72. jQuery(".profile_header_actions").prepend("<a class=\"btn_profile_action btn_medium\" target=\""+tab+"\" href=\""+url+id+"\"><span>Rocket League stats</span></a>");
  73. }else{
  74. jQuery(".profile_item_links").prepend("<div class=\"profile_count_link ellipsis\">\
  75. <a target=\""+tab+"\" href=\""+url+id+"\">\
  76. <span class=\"count_link_label\">Rocket League stats</span>&nbsp;\
  77. </a>\
  78. </div>");
  79. }
  80. });