本帖最后由 40252492 于 2022-10-28 14:03 编辑
本帖最后由 40252492 于 2022-10-28 14:01 编辑
谢谢大佬
我试了一下,进入战斗之后,到我选择卡片的地方,就是Select 1 card这个文本出现的时候,网页会直接未响应,只能关掉再开,反复几次都这样。(后攻在对手选完卡之后 自己选卡的时候未响应,先攻先选卡 直接未响应)
目前代码是下面这样的,我把帐号密码私聊给您,可能得麻烦进入战斗试一下啦谢谢!!!QAQ
// ==UserScript==
// @name 测试
// @namespace https://bbs.tampermonkey.net.cn/
// @version 0.1
// @description 测试
// @author 库X崔羊羊
// @match https://dulst.com/overdulst*
// @icon https://www.google.com/s2/favicons?domain=dulst.com
// @require https://greasyfork.org/scripts/450726-elementgetter1-2-0/code/ElementGetter120.js?version=1089539
// @license MIT
// ==/UserScript==
/* globals ElementGetter */
function listeneTextChange(target, callback) {
const mutationObserver = window.MutationObserver || window.WebkitMutationObserver || window.MozMutationObserver;
const observer = new mutationObserver(mutations => {
for (const mutation of mutations) {
if (mutation.type === 'characterData') callback();
for (const node of mutation.addedNodes) {
if (node.nodeType === 3) callback();
}
}
});
observer.observe(target, {
childList: true,
characterData: true,
subtree: true
});
}
const translation = new Map();
translation.set('Select 1 card', '选择1张卡');
translation.set(/Select (\d+) cards/, '选择$1张卡');
translation.set('Discard 1', '丢弃1张卡');
translation.set(/Discard (\d+)/, '丢弃$1张卡');
translation.set('Attack!', '攻击!');
const getwenben = new ElementGetter();
getwenben.each('#selectCardsReminder', document, div => {
listeneTextChange(div, () => {
let text = div.innerText;
if (text) {
for (const [k, v] of translation) {
text = text.replace(k, v);
}
}
div.innerText = text;
});
});