因此,我试图在每次访问任何nike.com运动鞋页面(没有HTML链接)时将其放在哪里,它会自动选择我的鞋子尺寸,并添加它到购物车,并检查出我。选择并激活AJAX驱动站点上的右侧控件
我目前正在尝试使用这个脚本(下面),但每次我去到运动鞋页面,它都没有正确添加我想要的鞋码,但只是直接去我的购物车没有结帐。
我被告知我需要将代码与实际页面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);
}
Link to the "target page"
Snapshot of the target HTML(如果目标页面被删除或由耐克改变)
'.selectBox标签[值= '10' ]'是一个jQuery选择器。它显然不匹配实际页面的HTML。禁用脚本,浏览页面,将Firefox的页面(** Ctrl ** + ** S **)保存为“Targetpage.htm”,然后将该文件('Targetpage.htm')上传到http:// pastebin.com/并链接到你的问题的pastebin。然后我们可以帮助你调整你的jQuery选择器。 – 2013-02-24 03:23:09
这里是目标页面,http://pastebin.com/6M7cMw40 – Nite 2013-02-24 03:31:56
这里是测试页面(targetpage)http://store.nike.com/us/en_us/?l=shop,pdp,ctr-inline/cid -1/pid-656545/pgid-656543 – Nite 2013-02-24 03:54:38