Greasy Fork镜像 支持简体中文。

RamisAmuki Utils

RamisAmuki Utils.

目前為 2023-07-29 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/469263/1227513/RamisAmuki%20Utils.js

  1. // ==UserScript==
  2. // @name RamisAmuki Utils
  3. // @description RamisAmuki Utils.
  4. // @author RamisAmuki
  5. // @grant none
  6. // ==/UserScript==
  7.  
  8. function check_rate_price(liqs, querys) {
  9. const li_rate_node = liqs(querys.rate);
  10. const li_rate = li_rate_node != null ? parseInt(li_rate_node.innerText) : 0;
  11. const li_price = parseInt(liqs(querys.price).innerText.replace(",", ""));
  12. let base_rate = Number(localStorage.getItem("rate-input") || 90);
  13. let base_price = Number(localStorage.getItem("price-input") || 100);
  14. return [li_rate < base_rate, li_price > base_price].every((b) => b);
  15. }
  16.  
  17. function disabling(li) {
  18. li.style.display = "none";
  19. }
  20.  
  21. function filter(checker, querys) {
  22. document
  23. .querySelectorAll(querys.lists)
  24. .forEach((li) => checker((q) => li.querySelector(q)) && disabling(li));
  25. }
  26.  
  27. function appendFilterButton(
  28. checker,
  29. querys,
  30. margin = null,
  31. innerHTML = "Filter",
  32. float = "right",
  33. height = "30px",
  34. color = "#000",
  35. backgroundColor = "#f6dbae"
  36. ) {
  37. // ボタン要素を作成
  38. let btn = document.createElement("button");
  39.  
  40. // ボタンを装飾
  41. btn.innerHTML = innerHTML;
  42. btn.style.float = float;
  43. btn.style.height = height;
  44. btn.style.color = color;
  45. btn.style.backgroundColor = backgroundColor;
  46. if (margin != null) btn.style.margin = margin;
  47.  
  48. // 実行する関数
  49. btn.onclick = () => filter(checker, querys);
  50.  
  51. // ボタンを追加
  52. document.querySelector(querys.button_parent).appendChild(btn);
  53. }
  54.  
  55. function appendRatePriceInput(querys) {
  56. appendRateInput(querys);
  57. appendPriceInput(querys);
  58. }
  59.  
  60. function appendRateInput(querys) {
  61. const input = document.createElement("input");
  62. const label = document.createElement("label");
  63.  
  64. input.type = "number";
  65. input.id = "rate-input";
  66. input.max = 99;
  67. input.min = 0;
  68. input.step = 1;
  69. input.value = localStorage.getItem(input.id) || 90; // nullだった場合、初期値にする
  70. input.onchange = () => {
  71. localStorage.setItem(input.id, input.value);
  72. };
  73. label.htmlFor = input.id;
  74. label.style.fontSize = "13px";
  75. label.innerText = "rate : ";
  76.  
  77. document.querySelector(querys.button_parent).appendChild(label);
  78. label.appendChild(input);
  79. console.log(label);
  80. console.log(input);
  81. }
  82.  
  83. function appendPriceInput(querys) {
  84. const input = document.createElement("input");
  85. const label = document.createElement("label");
  86.  
  87. input.type = "number";
  88. input.id = "price-input";
  89. input.min = 1;
  90. input.step = 1;
  91. input.value = localStorage.getItem(input.id) || 100;
  92. input.onchange = () => {
  93. localStorage.setItem(input.id, input.value);
  94. };
  95. label.htmlFor = input.id;
  96. label.style.fontSize = "13px";
  97. label.innerText = "price : ";
  98.  
  99. document.querySelector(querys.button_parent).appendChild(label);
  100. label.appendChild(input);
  101. console.log(label);
  102. console.log(input);
  103. }
  104.  
  105. function waitForElement(selector, callback, intervalMs, timeoutMs) {
  106. const startTimeInMs = Date.now();
  107. findLoop();
  108.  
  109. function findLoop() {
  110. if (document.querySelector(selector) != null) {
  111. callback();
  112. return;
  113. } else {
  114. setTimeout(() => {
  115. if (timeoutMs && Date.now() - startTimeInMs > timeoutMs) return;
  116. findLoop();
  117. }, intervalMs);
  118. }
  119. }
  120. }

QingJ © 2025

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