相关疑难解决方法(0)

在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) …
Run Code Online (Sandbox Code Playgroud)

javascript jquery greasemonkey tampermonkey

14
推荐指数
1
解决办法
1万
查看次数

在Greasemonkey脚本中,XPath没有在XHTML页面上选择正确的节点

我正在为weibo.com制作 Greasemonkey脚本.我无法在XHTML页面上使用XPath选择元素.

此代码无法获取我想要的元素:

function resolver(prefix) {
    return prefix === 'x' ? 'http://www.w3.org/1999/xhtml' : null;
}
var allLinks, thisLink;
allLinks = document.evaluate(
  "//x:a[@href]", 
  document, 
  resolver, 
  XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, 
  null 
);
Run Code Online (Sandbox Code Playgroud)

<a>选择侧栏上的元素,其余元素仍在那里.请参考这个weibo.com目标页面.

无论如何选择具有属性的所有元素action-type="login"

我用过"//x:a[@action-type='login']",但没用.

javascript xhtml xpath greasemonkey weibo

3
推荐指数
1
解决办法
695
查看次数

标签 统计

greasemonkey ×2

javascript ×2

jquery ×1

tampermonkey ×1

weibo ×1

xhtml ×1

xpath ×1