Humble Bundle - Steam Links Adder

Adds steam links to Humble Bundle games (https://greasyfork.org/en/scripts/26273-steam-store-game-owned-checker COMPATIBLE!) - Updated to work with lock icons, and to check shortened variants of names

  1. // ==UserScript==
  2. // @name Humble Bundle - Steam Links Adder
  3. // @icon https://humblebundle-a.akamaihd.net/static/hashed/47e474eed38083df699b7dfd8d29d575e3398f1e.ico
  4. // @namespace Royalgamer06
  5. // @version 1.2.2
  6. // @description Adds steam links to Humble Bundle games (https://greasyfork.org/en/scripts/26273-steam-store-game-owned-checker COMPATIBLE!) - Updated to work with lock icons, and to check shortened variants of names
  7. // @author Revadike
  8. // @contributor redion1992
  9. // @include *://www.humblebundle.com/*
  10. // @exclude *://www.humblebundle.com/home/*
  11. // @grant GM_xmlhttpRequest
  12. // @grant GM_addStyle
  13. // @run-at document-idle
  14. // @connect api.steampowered.com
  15. // @require http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.js
  16. // ==/UserScript==
  17.  
  18. // ==Configuration==
  19. const selectors = [".entity-title",
  20. ".deal-title",
  21. ".product-name",
  22. ".text-holder > h2",
  23. ".product-title > h2",
  24. "h1[data-entity-kind=product]",
  25. ".desktop:has(.hb-steam) .dd-image-box-caption",
  26. ".humble-original-title",
  27. ".game-name > h4",
  28. ".sr-key-heading > span"];
  29. // ==/Configuration==
  30.  
  31. // ==Code==
  32. GM_addStyle('.bundle-info-text a { visibility: visible; }');
  33. this.$ = this.jQuery = jQuery.noConflict(true);
  34. const selector = selectors.join(":not(.steamified):not(a):not(:has(a)), ") + ":not(.steamified):not(a):not(:has(a))";
  35. GM_xmlhttpRequest({
  36. method: "GET",
  37. url: "https://api.steampowered.com/ISteamApps/GetAppList/v2/",
  38. onload: response => {
  39. const applist = JSON.parse(response.responseText).applist.apps;
  40. $(document).ready(() => setInterval(() => $(selector).each((i, e) => steamify(e, applist)), 100));
  41. }
  42. });
  43.  
  44. function steamify(titleElem, applist) {
  45. $(titleElem).addClass("steamified");
  46. setTimeout(() => {
  47. let title = $(titleElem).text().toLowerCase().replace(/locked content|\(early access\)|\(pre\-order\)|\:|\-|\–|\\|\/|\™|\®| |\’|\`|\'|\.|\?|\!/g, "").trim();
  48. let obj = applist.filter(v => v.name.toLowerCase().replace(/\:|\-|\–|\\|\/|\™|\®| |\’|\`|\'|\.|\?|\!/g, "").trim() === title)[0];
  49. if (obj) {
  50. $(titleElem).wrapInner("<a style='color: inherit; z-index: -1;' href='http://store.steampowered.com/app/" + obj.appid + "/'></a>");
  51. } else {
  52. title = $(titleElem).text().toLowerCase().replace(/locked content|\(early access\)|\(pre\-order\)|\-|\–|\\|\/|\™|\®| |\’|\`|\'|\.|\?/g, "").split(":")[0].split("!")[0].trim();
  53. obj = applist.filter(v => v.name.toLowerCase().replace(/\:|\-|\–|\\|\/|\™|\®| |\’|\`|\'|\.|\?|\!/g, "").trim() === title)[0];
  54. if (obj) {
  55. $(titleElem).wrapInner("<a style='color: inherit; z-index: -1;' href='http://store.steampowered.com/app/" + obj.appid + "/'></a>");
  56. }
  57. }
  58. }, 0);
  59. }
  60. // ==/Code==