RamisAmuki Utils

RamisAmuki Utils.

2023-07-29 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://updategf.qytechs.cn/scripts/469263/1227513/RamisAmuki%20Utils.js

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

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