Sch*_*mix 3 javascript checkbox greasemonkey steam tampermonkey
某些站点(即 Steam 社区市场)要求用户手动选中特定复选框以进行重复操作,例如购买物品。
我希望始终选中该复选框。
http://steamcommunity.com/market/listings/730/USP-S%20%7C%20Torque%20(Field-Tested)
<input id="market_buynow_dialog_accept_ssa" type="checkbox" value="0" name="accept_ssa">
可以用 Tampermonkey 来完成吗?
我发现document.getElementById("checkbox").checked = true;
这对我来说似乎合乎逻辑。我把它放在一个新的 Tampermonkey 脚本中,并将 steam 市场添加到脚本激活的网站列表中,但它不起作用。
http://steamcommunity.com/market/listings/730/USP-S%20%7C%20Torque%20(Field-Tested)
那么我们可以假设开头的部分730
是易失性的,所以我们将用*
in替换它@include
。setInterval
基于(最著名的包装器是waitForKeyElements)。两者都是通过@require
钥匙插入的。// ==UserScript==
// @name Steam - accept the agreement
// @include http://steamcommunity.com/market/listings/*
// @require https://greasyfork.org/scripts/12228/code/setMutationHandler.js
// ==/UserScript==
// maybe the elements are already on the page
checkThem([].slice.call(document.querySelectorAll('input[type="checkbox"]')));
// but anyway set a MutationObserver handler for them
setMutationHandler(document, 'input[type="checkbox"]', checkThem);
function checkThem(nodes) {
nodes.forEach(function(n) { n.checked = true });
}
Run Code Online (Sandbox Code Playgroud)
更多信息:油脂点维基。