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
  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. let area = document.createElement("textarea");
  29. // Ignore games which do not have keys revealed
  30. let games = getGames().filter(e => e[1]);
  31. area.value = games.map(e => e[0]+","+e[1]).join("\n");
  32. area.style.width = "100%";
  33. const active = document.querySelector("ul.profile-private-page-library-sublist-active");
  34. active.append(area);
  35. area.style.height = area.scrollHeight + 20 + "px";
  36. }
  37.  
  38. function waitForBundleLoaded() {
  39. const loader = document.querySelector("ul.profile-private-page-library-sublist-active .profile-private-page-library-subitem-loading");
  40. if (loader && loader.style.display == "none") {
  41. injectTextbox();
  42. } else {
  43. setTimeout(waitForBundleLoaded, 100);
  44. }
  45. }
  46.  
  47. function injectLoaders() {
  48. const as = document.querySelectorAll(".profile-private-page-library-list .fit-click");
  49. as.forEach(a => {a.addEventListener("click", waitForBundleLoaded)});
  50. }
  51.  
  52. injectLoaders();
  53. injectTextbox();
  54. })();

QingJ © 2025

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