GOG additional buttons and downloads

Add GOG DB and GOG Games links to the GOG store

目前为 2023-05-31 提交的版本,查看 最新版本

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