我想使用Tampermonkey单击一个按钮,但出现此错误:userscript.html?id = 2514f475-79e4-4e83-a523-6fef16dceeaa:10617 Uncaught TypeError:targetNode.dispatchEvent不是triggerMouseEvent的函数...我的剧本:// ==UserScript==// @name Lootbits// @namespace http://tampermonkey.net/// @version 0.1// @description try to take over the world!// @author Zan Draklar// @match https://lootbits.io/*// @require https://code.jquery.com/jquery-3.4.0.js// ==/UserScript==var gems = 0$(document).ready(function() { if($('#claimbtn').length) { simulateMouseClick('#claimbtn'); }})function simulateMouseClick(targetNode) { function triggerMouseEvent(targetNode, eventType) { var clickEvent = document.createEvent('MouseEvents'); clickEvent.initEvent(eventType, true, true); targetNode.dispatchEvent(clickEvent); } ["mouseover", "mousedown", "mouseup", "click"].forEach(function(eventType) { triggerMouseEvent(targetNode, eventType); });}setInterval(function() { $("#lootbits").val(function(e) { gems = $(this).text(); }); if(gems>0) { $('#lootboxout > div > div > div.lootbox-side.lootbox-side-front').click() }}, 2000);setInterval(function() { location.reload()}, 605000);
2 回答
宝慕林4294392
TA贡献2021条经验 获得超8个赞
更改:SimulationMouseClick('#claimbtn'); 至:SimulationMouseClick($('#claimbtn'));
更改:targetNode.dispatchEvent(clickEvent); 到:document.querySelector(“#claimbtn”)。dispatchEvent(clickEvent);
添加回答
举报
0/150
提交
取消