RamisAmuki Utils

RamisAmuki Utils.

29.07.2023 itibariyledir. En son verisyonu görün.

Bu script direkt olarak kurulamaz. Başka scriptler için bir kütüphanedir ve meta yönergeleri içerir // @require https://updategf.qytechs.cn/scripts/469263/1227513/RamisAmuki%20Utils.js

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==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);
    }
  }
}