IndieGala Keys to TextArea

Displays a text area with game titles and keys.

当前为 2020-05-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IndieGala Keys to TextArea
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.1
  5. // @description Displays a text area with game titles and keys.
  6. // @author Lex
  7. // @match https://www.indiegala.com/library/bundle/*
  8. // @match https://www.indiegala.com/gift*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. function getGames() {
  16. const active = document.querySelector("ul.profile-private-page-library-sublist-active");
  17. const es = active.querySelectorAll(".profile-private-page-library-subitem");
  18. return Array.prototype.map.call(es, e => {
  19. const title = e.querySelector(".profile-private-page-library-title div").textContent.trim();
  20. const inps = e.getElementsByTagName("input");
  21. const key = (inps.length > 0) ? inps[0].value : "";
  22. return [title, key];
  23. });
  24. }
  25.  
  26. function injectTextbox() {
  27. console.log("Dumping keys");
  28. const active = document.querySelector("ul.profile-private-page-library-sublist-active");
  29. let area = active.querySelector("textarea.igktt");
  30. if (!area) {
  31. area = document.createElement("textarea");
  32. area.className = "igktt";
  33. active.append(area);
  34. }
  35. // Ignore games which do not have keys revealed
  36. let games = getGames().filter(e => e[1]);
  37. area.value = games.map(e => e[0]+","+e[1]).join("\n");
  38. area.style.width = "100%";
  39. area.style.height = "";
  40. area.style.height = area.scrollHeight + 20 + "px";
  41. }
  42.  
  43. function waitForBundleLoaded() {
  44. const loader = document.querySelector("ul.profile-private-page-library-sublist-active .profile-private-page-library-subitem-loading");
  45. if (loader && loader.style.display == "none") {
  46. injectTextbox();
  47. } else {
  48. setTimeout(waitForBundleLoaded, 100);
  49. }
  50. }
  51.  
  52. function injectLoaders() {
  53. const as = document.querySelectorAll(".profile-private-page-library-list .fit-click");
  54. as.forEach(a => {a.addEventListener("click", waitForBundleLoaded)});
  55. }
  56.  
  57. injectLoaders();
  58. injectTextbox();
  59. })();

QingJ © 2025

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