我的Greasemonkey脚本全部在Firefox 3.6中运行,但在Chrome 6中,当我加载一个应该触发它们的页面时,没有什么特别的事情发生。 Here是一个示例脚本(粘贴在下面),突出了对黑客新闻的顶级评论。任何人都可以识别我做错了什么?当我点击user.js文件并将其安装到Chrome中时,安装成功。为什么我的Greasemonkey脚本不能在Chrome中使用?
// ==UserScript==
// @name Hacker News highlight
// @namespace http://news.ycombinator.com
// @description highlights popular comments
// @include http://news.ycombinator.com/item*
// ==/UserScript==
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
// Check if jQuery's loaded
function GM_wait() {
if(typeof unsafeWindow.jQuery == 'undefined') { window.setTimeout(GM_wait,100); }
else { $ = unsafeWindow.jQuery; letsJQuery(); }
}
GM_wait();
function letsJQuery() {
var maxScore = 0;
var secBest = 0;
var min = 0;
var numComments = 0;
$(".comhead > span").each(function() {
numComments = numComments + 1;
var score = parseInt($(this).text().split(' ')[0]);
if(score > maxScore) {
maxScore = score;
}
else if(score > secBest) {
secBest = score;
}
});
min = maxScore - secBest;
$(".comhead > span").each(function() {
var score = parseInt($(this).text().split(' ')[0]);
if(min!=0 && score >= min + 1) {
$(this).css({'background-color':'#B2D7FB', 'padding':'4px 4px 4px 4px','-moz-border-radius':'3px', '-webkit-border-radius':'3x'});
}
});
}
为什么它的价值我有铬7.是否有可能在7添加greasemonkey支持? – Iznogood 2010-09-08 06:19:00
脚本是否适合你? Greasemonkey支持在二月份加入。 – RexE 2010-09-08 06:20:55
我在Ubuntu 10.04上运行Chromium 6.0.472.53,而GreaseMonkey脚本也不适用于我。 – Zaz 2010-09-08 06:49:37