2010-03-03 98 views
1

我有一个UserScript应该删除第一个mousemove事件上的某个类的所有图像。Greasemonkey onmousemove脚本

在写作Greasemonkey脚本方面相当新颖,好吧,这是我的第一个脚本,我认为这只是一些小小的缺失。

// ==UserScript== 
// @name aname 
// @namespace anamespace 
// @description adescription 
// @include  http://www.google.com/search* 
// @include  http://www.google.com/webhp* 
// @include  http://www.google.com/#* 
// @include  http://www.google.com/ 
// ==/UserScript== 
var removeTags = function() { 
    var allHTMLTags = window.document.getElementsByTagName("*"); 
    for (i=0; i < allHTMLTags.length; i++) { 
     if (allHTMLTags[i].className == "l sb-l") { 
      allHTMLTags[i].style.display='none'; 
     } 
    } 
}; 
document.captureEvents(Event.MOUSEMOVE); 
document.onmousemove = removeTags; 

感谢您的帮助!

回答

1

尝试addEventListener

window.addEventListener('mousemove',removeTags,false); 
+0

谢谢,这是快! – 2010-03-03 10:22:50

+0

我很高兴知道它的工作原理。 – YOU 2010-03-03 10:23:45