在ajax驱动的站点上选择并激活正确的控件。所以,我试着在每次访问任何nike.com运动鞋页面(没有HTML链接)时,都会自动选择我的鞋号,并将其添加到购物车中,并为我检查。我目前正在尝试使用这个脚本(下面),但每次我去运动鞋页面,它没有适当地添加我想要的鞋大小,但只是直接去结账,没有在我的手推车。有人告诉我,我需要将代码与实际的页面HTML相匹配,但我不知道如何做到这一点。请帮帮忙。// ==UserScript==// @name _Nike auto-buy(!!!) script// @include http://*/*// @require
http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js// @require https://gist.github.com/raw/2625891/waitForKeyElements.js// @grant
GM_addStyle// ==/UserScript==/*- The @grant directive is needed to work around a design change
introduced in GM 1.0. It restores the sandbox.
*/var okayToClickAddtoCart = false;//-- Assumes that size is a standard <option> tag or similar...waitForKeyElements
(".selectBox-label[value='10']", selectShoeSize);function selectShoeSize (jNode) {
jNode.prop ('selected', true);
okayToClickAddtoCart = true;}waitForKeyElements (".add-to-cart.nike-button", clickAddToCart);function clickAddToCart (jNode) {
if ( ! okayToClickAddtoCart) {
return true; //-- Don't click yet.
}
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('click', true, true);
jNode[0].dispatchEvent (clickEvent);}waitForKeyElements (".checkout-button", clickCheckoutButton);function clickCheckoutButton (jNode) {
var clickEvent = document.createEvent ('MouseEvents');
clickEvent.initEvent ('click', true, true);
jNode[0].dispatchEvent (clickEvent);}链接到“目标页”目标HTML的快照(如果耐克移除或更改目标页面)
添加回答
举报
0/150
提交
取消