【发布时间】:2010-05-27 04:04:41
【问题描述】:
我正在编写一个 Greasemonkey 脚本,我想通过使用 XPath 选择出现在某个用户名之后的帖子正文来更改 phpBB2 论坛上的论坛帖子的文本,但整个事情是一个巨大的乱七八糟的桌子。
<tr>
<td>
<span class="name">
<a>
<b>username</b>
</span>
<span></span>
</td>
<td>
<table>
<tbody>
<tr></tr>
<tr></tr>
<tr>
<td>
<span class="postbody">text of post</span>
<span></span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
我需要获取在 b 标记中的用户名等于某个名称之后发生的 postbody 跨度,然后将文本弄乱。以下是我的尝试:
var postguy = document.evaluate('fffffff', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
for (var i = 0; i < postguy.snapshotLength; i++) {
thisLink = postguy.snapshotItem(i);
//then do something with the post
}
【问题讨论】:
标签: xpath greasemonkey phpbb