2012-05-16 140 views
-1

我試圖刪除由「滾動」插件添加到頁面中的keydown事件處理程序。Greasemonkey:刪除由插件添加的事件處理程序

頁是這樣的: http://www.nacion.com/2012-05-15/Mundo/nobel-de-economia-cree-posible-pronta-desaparicion-de-zona-euro-.aspx

基本上我想,當我用下/上箭頭我的鍵盤上的Page下降,而不是在插件應用的小方塊。 我試着得到插件的一個實例,但由於某種原因,它一旦加載頁面就不可用。

另一種方法是強制在加載頁面腳本之前加載greasemonkey腳本(因此我可以使用greasemonkey將其刪除),但我不知道這是否可能。

任何想法,將不勝感激。

感謝

回答

0

該網頁似乎使用的jQueryTOOLS Scrollable自定義或越野車實施。

糟糕的UI體驗是通過這個代碼在主網頁觸發:

<script> 
    // initialize scrollable para ademas 
    jQuery(document).ready(function() { 
     $("div.scroller_ademas").scrollable({ 
      size: 1, 
      items: '#ademasaldea', 
      vertical: true 
     }).mousewheel({ 
      items: '#ademasaldea' 
     }); 
    }); 
</script> 

而且所有的unbind()電話和keyboard = false集,應該工作,不影響鍵盤劫持!

幸運的是,冒犯的<script>是相當原子的,所以Greasemonkey可以阻止那個有問題的JS而不會影響其他任何東西。

通過使用the stunningly-brilliant checkForBadJavascripts utility來阻止JS。

像這樣:

// ==UserScript== 
// @name  _Block scrollable that's run amuck. 
// @namespace _pc 
// @include  http://www.nacion.com/* 
// @run-at  document-start 
// @require  https://gist.github.com/raw/2620135/checkForBadJavascripts.js 
// ==/UserScript== 

checkForBadJavascripts ([ 
    [false, /items\:\s+'\#ademasaldea'/, null] 
]); 

注意,這也將受益於被滾動停止「Ademas恩世界報」框中,但您可以修復通過添加

window.addEventListener ("load", function() { 
    GM_addStyle ('#ademasaldea { height: 100%; overflow-y: scroll; }'); 
}, false); 

到腳本。

+0

哇,非常感謝。我很高興我不是太遠:P永遠不會自己找到checkForBadJavascripts。 – willvv

+0

實際上,我在測試之前感謝了它,這很奇怪,但它不會阻止腳本。行爲得到維護。 – willvv

+0

我自己測試了這個腳本,它可以工作。你正在使用Firefox和Greasemonkey,對吧?每個版本有哪些版本?您是否有或需要登錄才能看到問題? –