您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a new word's context menu from its top deck in JPDB reviews
当前为
// ==UserScript== // @name Leech Display // @namespace jpdb.io // @version 0.1.0 // @description Adds a new word's context menu from its top deck in JPDB reviews // @author daruko // @match https://jpdb.io/review* // @icon https://www.google.com/s2/favicons?sz=64&domain=jpdb.io // @grant none // @license The Unlicense // ==/UserScript== (function() { 'use strict'; window.LeechThreshold = {}; // How many times a card has to be answered Nothing / Something to count as a leech window.LeechThreshold.threshold = 4 // How many times a card has to be answered correctly before to be valid for the Threshold window.LeechThreshold.newProtection = 4 // Show New Card Indicator window.LeechThreshold.showNewIndicator = true window.LeechThreshold.init = () =>{ // Code from daruko - JPDB add context menu in reviews // https://gf.qytechs.cn/en/scripts/471987-jpdb-add-context-menu-in-reviews const wordUri = document.querySelector('.review-reveal .answer-box a[href^="/vocabulary"]')?.href; const deckUri = document.querySelector('.review-reveal a[href^="/deck"]')?.href; if (!wordUri || !deckUri) { return; } const [,, wordId, word] = new URL(wordUri).pathname.split('/', 4); if (!word) { return; } fetch(`https://jpdb.io/vocabulary/${wordId}/${word}/review-history`) .then((response) => response.text()) .then((text) => { const html = new DOMParser().parseFromString(text, "text/html"); window.LeechThreshold.getLeechCount(html) }) .catch((err) => { console.error('An error has occurred.', err); }); // End }; window.LeechThreshold.getLeechCount = (xml) =>{ const threshold = window.LeechThreshold.threshold; let current = 0 let isReady = false; let isReadyCount = 0; let debugLog = []; const histories = xml.querySelectorAll(".review-history > div"); histories.forEach((historie, index) =>{ var state = historie.children[2].textContent; if (isReady){ if (state == "Nothing" || state == "Something"){ current++; } debugLog.push(state) } else { debugLog.push('[Skip] ' + state ) if (state == "Nothing" || state == "Something"){ isReadyCount = 0 } else { isReadyCount++; if (isReadyCount >= 4){ isReady = true; } } } }); console.log(histories.length, debugLog) const info = document.createElement("div"); info.innerHTML = ""; info.style.color = "green" info.style.position = "absolute" if (current >= threshold){ info.style.color = "red" info.innerHTML = "> Leech <"; } if (!isReady && window.LeechThreshold.showNewIndicator){ info.innerHTML = "New"; } document.querySelector(".plain").prepend(info) const info2 = document.createElement("div"); info2.innerHTML = `Contamination ${current}/${threshold}`; info2.style.color = "#bbb" document.querySelector(".vbox.gap").append(info2) } window.LeechThreshold.init(); if (document.querySelector("#show-answer")) document.querySelector("#show-answer").addEventListener("click", ()=>{ setTimeout(window.LeechThreshold.init,1) }) // Your code here... })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址