BaiduMonkey

By SUCCESS Last update Sep 20, 2010 — Installed 47,347 times.

脚本未考虑赞助商的情况

in
Subscribe to 脚本未考虑赞助商的情况 2 posts, 2 voices



jishuxingxia... User
bd里有赞助商链接,灰色背景的。 
比如搜“医院”是一种情况,搜“匿名网页代理”也是一种情况 

所以对分栏函数作了一点修改。 

谢谢您做的这个脚本,非常好用!!! 
// 分栏
function movePops_and_MultiCol(doc, pagecount, Pref){
    var i, len;
    
    /************FIX**FIX**FIX**FIX*************/ 
    // 删除没用的 
。remove /@class="f" var Brs = matchNode('//br[preceding-sibling::table[tbody/tr/td]]',doc); len = Brs.snapshotLength; if (len > 0) { for (i = 0; i < len; i++) { var Br = Brs.snapshotItem(i); Br.parentNode.removeChild(Br); } } /************FIX**FIX**FIX**FIX*************/ // 在第一个条目前插入一个 DIV ,id = bm_page_1,2,3,etc,用来容纳搜索结果条目。 var firstTable = matchNode('//table[(tbody/tr/td[@class="f"] and not(parent::div[parent::td])) or (parent::body and tbody/tr/td/div/table/tbody/tr/td[@class="f"])]',doc).snapshotItem(0); var resContainer = document.createElement('div'); resContainer.setAttribute('id', 'bm_page_' + pagecount); firstTable.parentNode.insertBefore(resContainer, firstTable); // 移动“推广”条目 var popTables = matchNode('//table[tbody/tr/td/@class="f"][descendant::a[text() = "推广"]]',doc); len = popTables.snapshotLength; if (len > 0) { // popContainer 用来盛放推广条目,将它添加在搜索结果 DIV 之前 var popContainer = document.createElement('div'); resContainer.parentNode.insertBefore(popContainer, resContainer); var popContainerTable = document.createElement('table'); popContainerTable.innerHTML = '    <font>共有' + len + '条推广链接,点此 显示/隐藏 </font>

'; popContainer.appendChild(popContainerTable); var popDiv = document.getElementById('popDiv'); popDiv.style.display = 'none'; // 添加显示、隐藏“推广”条目的事件 document.getElementById('togglePops').addEventListener('click', function(){popDiv.style.display = popDiv.style.display == 'none' ? '' : 'none';}, false); for (i = 0; i < len; i++) { var popTable = popTables.snapshotItem(i); popTable.setAttribute('class', 'rest'); popDiv.appendChild(popTable); // 移动结果 Table } } /************FIX**FIX**FIX**FIX*************/ // 删除没用的 sponsor table var sponsorTables = matchNode('//body/table[@style="width: 65%; margin-left: 12px; background-color: rgb(245, 245, 245);" or (@width="65%" and @bgcolor="#f5f5f5")]', doc); len = sponsorTables.snapshotLength; if (len > 0) { for (i = 0; i < len; i++) { var sponsorTable = sponsorTables.snapshotItem(i); sponsorTable.parentNode.removeChild(sponsorTable); } } // 移动搜索结果条目 resContainer.setAttribute('id','bm_page_' + pagecount); // 如果打开了设置界面,那么不添加 class ,使得设置界面中的预览能够正常变化 if(!document.getElementById('preferences')) resContainer.setAttribute('class','bm_MultiColDiv'); var resTables = matchNode('//table[tbody/tr/td/@class="f"][not(descendant::a[text() = "推广"])]', doc); len = resTables.snapshotLength; if (len > 0) { var cols = Pref.columns; var resTable; // 设置搜索结果的排列方向。1-横向;2-纵向 switch (Pref.direction) { case 1: for (var j = 0; j < cols; j++) { for (i = j; i < len; i += cols) { resTable = resTables.snapshotItem(i); resTable.setAttribute('class', 'rest'); resContainer.appendChild(resTable); // 移动结果 Table } } break; case 2: for (i = 0; i < len; i++) { resTable = resTables.snapshotItem(i); resTable.setAttribute('class', 'rest'); resContainer.appendChild(resTable); // 移动结果 Table } break; } } }
 
FoxHound User
FirefoxWindows

比较简单的办法,在自定义CSS内添加代码如下,隐藏推广链接:
table[bgcolor="#f5f5f5"] { display: none !important; }

P.S.以上方法带来的一个好处是不会出现用JS脚本时推广链接会一闪而过的毛病。

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel