Userscript to click button

青春壹個敷衍的年華 提交于 2019-12-04 10:44:05

I wonder if the code below is what you want.

document.querySelector('#buy-now').click()

Demo

It seems some scripts have not been loaded on the page you mentioned at the time of DOMContentLoaded. Adding a delay solved the problem for me, that is,

// ==UserScript==
// @name         script
// @namespace    sc
// @include      http://www.aliexpress.com/item/Free-shipping-100-Genuine-Original-P1000-Mobile-phone-data-cable-for-Samsung-P1000-P6800-P7500-USB/1477114758.html
// @version      1
// @description  http://stackoverflow.com/questions/22633509/userscript-to-click-button/22684724
// @grant        none
// ==/UserScript==
setTimeout(function() {
    document.querySelector('#buy-now').click()
}, 1000)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!