2013-01-08 41 views

回答

3

假设这是一个精确确切的XPath,则可以使用document.evaluate以除去该表中,如下所示:

var badTableEval = document.evaluate (
    "//body/center/center/table", 
    document.documentElement, 
    null, 
    XPathResult.FIRST_ORDERED_NODE_TYPE, 
    null 
); 

if (badTableEval && badTableEval.singleNodeValue) { 
    var badTable = badTableEval.singleNodeValue; 
    badTable.parentNode.removeChild (badTable); 
} 



或使用相应的jQuery。这是一个完整的脚本

// ==UserScript== 
// @name  YOUR_SCRIPT_NAME 
// @include http://YOUR_SERVER.COM/YOUR_PATH/* 
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.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. 
*/ 

$("body > center:first > center:first > table:first").remove(); 


jQuery有a powerful collection of selectors使用jQuery将支付巨额股息速度,易用性,和脚本的鲁棒性。

+0

我想我会开始阅读有关jquery它似乎很简单 再次感谢您的帮助 最好的问候 –

+0

不客气;乐意效劳。 –

相关问题