Greasy Fork is available in English.

Discussions » Development

为什么只能点击一次!!!啊啊啊

§
Posted: 31 Mei 2021

如下所示代码,我写的这个油猴想实现点一下后点某个按键很多次,但我加了循环之后还是只能点一次!!!什么鬼,卡半天了!大佬们有解决方法吗?感激不尽!!

(function () {
    $('#root').before('<input type="button" id="google" value="Google一下" class="btn self-btn bg s_btn" style="background-color:grey;" />');
    $("#google").click(function () {
        let target = document.querySelector("div#content img.switch-next")
        let target2 = document.querySelector('div#content button[type="button"]')
        for(let i=0;i<5;i++){
            if(target){
                target.click()
            }
            if(target2){
               target2.click();
            }
            sleep(1)
        }

    });

§
Posted: 31 Mei 2021

1在线等

Post reply

Sign in to post a reply.