IG礼物链接提取

Indiegala礼物链接提取

  1. // ==UserScript==
  2. // @name:zh-CN IG礼物链接提取
  3. // @name Extract_Gift_link_Indiegala
  4. // @namespace https://blog.chrxw.com/
  5. // @version 0.8
  6. // @description:zh-CN Indiegala礼物链接提取
  7. // @description Indiegala礼物链接提取
  8. // @author Chr_
  9. // @license AGPL-3.0
  10. // @icon https://blog.chrxw.com/favicon.ico
  11. // @match https://www.indiegala.com/library
  12. // @grant GM_setClipboard
  13. // ==/UserScript==
  14.  
  15. (() => {
  16. "use strict";
  17.  
  18. let GObjs = {};
  19.  
  20. addbtn();
  21. function addbtn() {
  22. let area = document.querySelector("div.profile-private-page-user");
  23. let dv1 = document.createElement("div");
  24. let dv2 = document.createElement("div");
  25. let dv3 = document.createElement("div");
  26. let btnExtractGift = document.createElement("button");
  27. let btnExtractKey = document.createElement("button");
  28. let btnCopy = document.createElement("button");
  29. let btnClear = document.createElement("button");
  30. let txtResult = document.createElement("textarea");
  31. dv1.style.cssText = "margin: 12px 0;display: flex;";
  32. dv2.style.cssText = "margin: 0 12px;display: block;";
  33. dv3.style.cssText = "margin: 0 12px;display: block;";
  34. btnExtractGift.addEventListener("click", extractGift);
  35. btnExtractKey.addEventListener("click", extractKey);
  36. btnCopy.addEventListener("click", copy);
  37. btnClear.addEventListener("click", clear);
  38. btnExtractGift.style.cssText = "display: inherit;";
  39. btnClear.style.cssText = "float: right;";
  40. btnExtractGift.textContent = "提取礼物链接";
  41. btnExtractKey.textContent = "提取Key";
  42. btnCopy.textContent = "复制";
  43. btnClear.textContent = "×";
  44. btnCopy.id = "btnCopy";
  45. txtResult.style.cssText = "width: 70%;white-space: nowrap;";
  46. txtResult.id = "extractLinks";
  47. dv2.appendChild(btnExtractGift);
  48. dv2.appendChild(btnExtractKey);
  49. dv3.appendChild(btnCopy);
  50. dv3.appendChild(btnClear);
  51. dv1.appendChild(dv2);
  52. dv1.appendChild(txtResult);
  53. dv1.appendChild(dv3);
  54. area.appendChild(dv1);
  55. Object.assign(GObjs, { txtResult, btnCopy });
  56. }
  57. function extractGift() {
  58. const { txtResult } = GObjs;
  59. let gifts = document.querySelectorAll("div[ref=bundle] ul.profile-private-page-library-sublist-active div.profile-private-page-library-gifts div.profile-private-page-library-gift-title > div.overflow-auto");
  60. if (gifts.length > 0) {
  61. let list = [];
  62. let old = txtResult.value;
  63. for (let gift of gifts) {
  64. let giftLink = gift.querySelector("a").href;
  65. let giftPass = gift.querySelector("div:last-child>span").textContent;
  66. if (old.indexOf(giftLink.substring(38,)) >= 0) {
  67. console.log(`重复的礼物链接 ${giftLink.substring(38,)}`);
  68. continue;
  69. }
  70. list.push(`IG慈善包链接:( ${giftLink} IG慈善包密码:( ${giftPass} )`);
  71. }
  72. if (list.length > 0) {
  73. if (txtResult.value !== "") {
  74. txtResult.value += "\n";
  75. }
  76. txtResult.value += list.join("\n");
  77. }
  78. } else {
  79. alert("未找到可识别的礼物链接");
  80. }
  81. copy();
  82. }
  83. function extractKey() {
  84. const { txtResult } = GObjs;
  85. let cols = document.querySelectorAll("ul.profile-private-page-library-sublist-active div.profile-private-page-library-key-cont.overflow-auto");
  86. if (cols.length > 0) {
  87. let list = [];
  88. let old = txtResult.value;
  89. for (let col of cols) {
  90. const gameName = col.querySelector("div.profile-private-page-library-title-row-full")?.title ?? "";
  91. const gameKey = col.querySelector("input")?.value ?? "";
  92.  
  93. if (old.indexOf(gameKey) >= 0) {
  94. console.log(`重复的key ${giftLink.substring(38,)}`);
  95. continue;
  96. }
  97. list.push(`${gameName} ${gameKey}`);
  98. }
  99. if (list.length > 0) {
  100. if (txtResult.value !== "") {
  101. txtResult.value += "\n";
  102. }
  103. txtResult.value += list.join("\n");
  104. }
  105. } else {
  106. alert("未找到可识别的Key信息");
  107. }
  108. copy();
  109. }
  110. function copy() {
  111. const { btnCopy, txtResult } = GObjs;
  112. GM_setClipboard(txtResult.value, "text");
  113. btnCopy.textContent = "已复制";
  114. setTimeout(() => { btnCopy.textContent = "复制"; }, 1000);
  115. }
  116. function clear() {
  117. const { txtResult } = GObjs;
  118. if (confirm("确定要清空吗?")) {
  119. txtResult.value = "";
  120. }
  121. }
  122. })();

QingJ © 2025

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