2013-01-08 38 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

不客氣;樂意效勞。 –

相關問題