GOG additional buttons and downloads

Add GOG DB and GOG Games links to the GOG store

当前为 2023-06-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GOG additional buttons and downloads
  3. // @homepageURL https://gog-games.com/
  4. // @description Add GOG DB and GOG Games links to the GOG store
  5. // @version 4.0.5
  6. // @author Wizzergod
  7. // @license MIT
  8. // @namespace GOG additional buttons and downloads
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=www.gog.com
  10. // @run-at document-end
  11. // @match https://www.gog.com/*/game/*
  12. // @match https://www.gog.com/game/*
  13. // @grant unsafeWindow
  14. // ==/UserScript==
  15.  
  16.  
  17. (function() {
  18. var productcardData = unsafeWindow.productcardData;
  19. var product_id = productcardData.cardProductId;
  20. var product_slug = productcardData.cardProductSlug;
  21. var product_title = productcardData.cardProduct.title;
  22.  
  23. var separator_element = document.createTextNode(" ");
  24.  
  25. function addLink(text, href, className, targetElement) {
  26. var link_element = document.createElement("a");
  27. link_element.textContent = text;
  28. link_element.setAttribute("href", href);
  29. link_element.className = className;
  30. link_element.setAttribute("target", "_blank");
  31. link_element.style = "margin: 5px 0 5px 0 !important; padding: 5px 10px 5px 10px;";
  32.  
  33. targetElement.parentNode.insertBefore(separator_element.cloneNode(true), targetElement.nextSibling);
  34. targetElement.parentNode.insertBefore(link_element, targetElement.nextSibling);
  35. }
  36.  
  37. var mainButtonDeciderElement = document.querySelector("div[main-button-decider].ng-scope");
  38. if (mainButtonDeciderElement) {
  39. addLink("View on GOGdb", "https://www.gogdb.org/product/" + product_id, "button button--big cart-button ng-scope", mainButtonDeciderElement);
  40. addLink("Download Free from - GoGUnlocked", "https://gogunlocked.com/?s=" + product_title, "button button--big cart-button ng-scope", mainButtonDeciderElement);
  41. addLink("Download Free from - Gog-Games", "https://gog-games.com/game/" + product_slug, "button button--big cart-button ng-scope", mainButtonDeciderElement);
  42. addLink("Download Free from - FreeGogPcGames", "https://freegogpcgames.com/?s=" + product_slug, "button button--big cart-button ng-scope", mainButtonDeciderElement);
  43. }
  44.  
  45.  
  46. element.style = "margin: 5px 0 5px 0 !important; padding: 5px 10px 5px 10px;";
  47.  
  48. })();