Steam hltb

Finally, HLTB on Steam page

  1. // ==UserScript==
  2. // @name Steam hltb
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Finally, HLTB on Steam page
  6. // @author Vincenzo Canfora
  7. // @match https://store.steampowered.com/app/*/*
  8. // @run-at document-end
  9. // @require https://code.jquery.com/jquery-3.5.1.min.js
  10. // @grant GM_xmlhttpRequest
  11. // @connect herokuapp.com
  12. // ==/UserScript==
  13.  
  14. /* jshint esversion: 6 */
  15.  
  16. const gameName = filterGameName(jQuery('.apphub_AppName').text(), '\w');
  17. const gifCaricamento = '<img id="gifCaricamento" src="https://steamstore-a.akamaihd.net/public/shared/images/throbber.gif" style="margin-left: 7px" width="25" height="25">';
  18. const silenoid = '<div id="silenoid" class="glance_ctn_responsive_left"></div>';
  19.  
  20. jQuery(".game_description_snippet").after(silenoid);
  21.  
  22. //---------------------------------------------------------------------------------------HLTB
  23. const hltbButton = '<div id="hltbButton" class="btnv6_blue_hoverfade btn_medium" style="margin-top: 7px; margin-bottom: 7px;"><span>Get HLTB data</span></div>';
  24.  
  25. jQuery("#silenoid").append(hltbButton);
  26.  
  27. jQuery("#hltbButton").click(function() {
  28. jQuery("#hltbButton").off('click');
  29. jQuery("#hltbButton").after(gifCaricamento);
  30. getRequest("GET", "https://silenoids-services.herokuapp.com/hltb/" + gameName).then(response => {
  31. jQuery("#gifCaricamento").remove();
  32. if(!jQuery.isEmptyObject(response)){
  33. jQuery("#hltbButton").after(
  34. addTextLine('Main: ' + response[0].gameplayMain) + addTextLine('Main + Extra: ' + response[0].gameplayMainExtra) + addTextLine('Completionist: ' + response[0].gameplayCompletionist)
  35. );
  36. } else {
  37. jQuery("#hltbButton").after(addTextLine("Data not found for " + gameName));
  38. }
  39. });
  40. });
  41.  
  42. //---------------------------------------------------------------------------------------FUNCTIONS
  43. function addSpace() {
  44. return '</br>'
  45. }
  46.  
  47. function addTextLine(text, marginTop) {
  48. return '<div class="game_description_snippet">' + text + '</div>';
  49. }
  50.  
  51. function getRequest(type, url) {
  52. let uri = encodeURI(url);
  53. console.log("Request to " + uri);
  54. return new Promise( function(resolve,reject) {
  55. GM_xmlhttpRequest({
  56. method: type,
  57. url: uri,
  58. onload: function(response) {
  59. resolve(jQuery.parseJSON(response.response));
  60. }
  61. });
  62. })
  63. }
  64.  
  65. function filterGameName(gameName) {
  66. return filterString(gameName, /[A-z]+/g);
  67. }
  68.  
  69. function filterString(textToFilter, admittedCharRegex) {
  70. console.log('Filtering ', textToFilter, ' with ', admittedCharRegex);
  71. return (textToFilter.match(admittedCharRegex || []).join(' '));
  72. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址