IsThereAnyDeal with thumbnails

Displaying game thumbnails next to the deals

  1. // ==UserScript==
  2. // @name IsThereAnyDeal with thumbnails
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Displaying game thumbnails next to the deals
  6. // @author Zoltan Wacha - steampeek.hu (find similar games)
  7. // @match https://isthereanydeal.com/*
  8. // @exclude https://isthereanydeal.com/waitlist/*
  9. // @exclude https://isthereanydeal.com/collection/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. var refreshTimer = null;
  14.  
  15. let observer = new MutationObserver(mutationsList => {
  16. for (let mutation of mutationsList)
  17. {
  18. if (mutation.type === 'childList')
  19. {
  20. clearTimeout(refreshTimer);
  21. refreshTimer = setTimeout(function () {
  22. updateThumbs();
  23. }, 250);
  24. }
  25. }
  26. });
  27.  
  28. observer.observe(document, {childList: true, subtree: true});
  29.  
  30. function GM_main ($) {
  31. $("body").prepend("<style>.itadthumb{width:96px;height:36px;background-repeat:no-repeat;background-position:center;background-size:contain;display:inline-block;margin:0 10px 0 0;flex:none;} .itadthumb.nothumb{background-color: #6f6f6f;background-size: 50%;opacity: 0.1;background-image:url(https://d2uym1p5obf9p8.cloudfront.net/images/logo.png)} .itadthumb.placeholder{opacity: 0.3;background-size: 65%;} .gameinfocontainer{flex:1;}</style>");
  32.  
  33. clearTimeout(refreshTimer);
  34. refreshTimer = setTimeout(function () {
  35. updateThumbs();
  36. }, 250);
  37. }
  38.  
  39. function updateThumbs() {
  40. let thumbadded = false;
  41. let lnk = null;
  42. let steamid = null;
  43.  
  44. $("#games > .game:not(.thumbnailhandled)").each(function(index) {
  45. {
  46. thumbadded = false;
  47. lnk = $(this).find('.noticeable').attr('href');
  48.  
  49. $(this).wrapInner("<div class='gameinfocontainer'></div>");
  50.  
  51. if($(this).data("steamid") && $(this).data("steamid").startsWith('app'))
  52. {
  53. steamid = $(this).data("steamid");
  54. steamid = steamid.replace("app", "apps");
  55.  
  56. if(steamid)
  57. {
  58. $(this).prepend("<a href='"+lnk+"' class='itadthumb' style='background-image:url(https://steamcdn-a.akamaihd.net/steam/"+steamid+"/capsule_184x69.jpg)'></a>");
  59. thumbadded = true;
  60. }
  61. }
  62.  
  63. if(!thumbadded)
  64. {
  65. $(this).prepend("<a href='"+lnk+"' class='itadthumb nothumb'></a>");
  66. }
  67.  
  68. $(this).css("display", "flex");
  69. $(this).css("align-items", "center");
  70.  
  71. $(this).addClass("thumbnailhandled");
  72. }
  73. });
  74. }
  75.  
  76. if (typeof jQuery === "function") {
  77. GM_main(jQuery);
  78. }