🏠 返回首頁 

Greasy Fork is available in English.

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