Greasy Fork 还支持 简体中文。

RamisAmuki Utils

RamisAmuki Utils.

La data de 29-07-2023. Vezi ultima versiune.

Acest script nu ar trebui instalat direct. Aceasta este o bibliotecă pentru alte scripturi care este inclusă prin directiva meta a // @require https://updategf.qytechs.cn/scripts/469263/1227513/RamisAmuki%20Utils.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         RamisAmuki Utils
// @description  RamisAmuki Utils.
// @author       RamisAmuki
// @grant        none
// ==/UserScript==

function check_rate_price(liqs, querys) {
  const li_rate_node = liqs(querys.rate);
  const li_rate = li_rate_node != null ? parseInt(li_rate_node.innerText) : 0;
  const li_price = parseInt(liqs(querys.price).innerText.replace(",", ""));
  let base_rate = Number(localStorage.getItem("rate-input") || 90);
  let base_price = Number(localStorage.getItem("price-input") || 100);
  return [li_rate < base_rate, li_price > base_price].every((b) => b);
}

function disabling(li) {
  li.style.display = "none";
}

function filter(checker, querys) {
  document
    .querySelectorAll(querys.lists)
    .forEach((li) => checker((q) => li.querySelector(q)) && disabling(li));
}

function appendFilterButton(
  checker,
  querys,
  margin = null,
  innerHTML = "Filter",
  float = "right",
  height = "30px",
  color = "#000",
  backgroundColor = "#f6dbae"
) {
  // ボタン要素を作成
  let btn = document.createElement("button");

  // ボタンを装飾
  btn.innerHTML = innerHTML;
  btn.style.float = float;
  btn.style.height = height;
  btn.style.color = color;
  btn.style.backgroundColor = backgroundColor;
  if (margin != null) btn.style.margin = margin;

  // 実行する関数
  btn.onclick = () => filter(checker, querys);

  // ボタンを追加
  document.querySelector(querys.button_parent).appendChild(btn);
}

function appendRatePriceInput(querys) {
  appendRateInput(querys);
  appendPriceInput(querys);
}

function appendRateInput(querys) {
  const input = document.createElement("input");
  const label = document.createElement("label");

  input.type = "number";
  input.id = "rate-input";
  input.max = 99;
  input.min = 0;
  input.step = 1;
  input.value = localStorage.getItem(input.id) || 90; // nullだった場合、初期値にする
  input.onchange = () => {
    localStorage.setItem(input.id, input.value);
  };
  label.htmlFor = input.id;
  label.style.fontSize = "13px";
  label.innerText = "rate : ";

  document.querySelector(querys.button_parent).appendChild(label);
  label.appendChild(input);
  console.log(label);
  console.log(input);
}

function appendPriceInput(querys) {
  const input = document.createElement("input");
  const label = document.createElement("label");

  input.type = "number";
  input.id = "price-input";
  input.min = 1;
  input.step = 1;
  input.value = localStorage.getItem(input.id) || 100;
  input.onchange = () => {
    localStorage.setItem(input.id, input.value);
  };
  label.htmlFor = input.id;
  label.style.fontSize = "13px";
  label.innerText = "price : ";

  document.querySelector(querys.button_parent).appendChild(label);
  label.appendChild(input);
  console.log(label);
  console.log(input);
}

function waitForElement(selector, callback, intervalMs, timeoutMs) {
  const startTimeInMs = Date.now();
  findLoop();

  function findLoop() {
    if (document.querySelector(selector) != null) {
      callback();
      return;
    } else {
      setTimeout(() => {
        if (timeoutMs && Date.now() - startTimeInMs > timeoutMs) return;
        findLoop();
      }, intervalMs);
    }
  }
}