Javascript 润滑油猴子脚本不';t运行-第一次脚本尝试

Javascript 润滑油猴子脚本不';t运行-第一次脚本尝试,javascript,greasemonkey,Javascript,Greasemonkey,好的,我已经创建了一个小脚本,我想根据页面上一些标记中的数据更改表行的格式。脱机时,该脚本工作正常,但我正在尝试将其改编为greasemonkey的用户脚本,首先,我的脚本不会通过网站安装,其次,当我使用“新用户脚本”在本地安装时它似乎什么也不做,控制台也没有任何记录,以下是我的代码: // // ==UserScript== // @name Cerberus Time-since Row Colouring // @author David Duke, Luke Mulholland

好的,我已经创建了一个小脚本,我想根据页面上一些标记中的数据更改表行的格式。脱机时,该脚本工作正常,但我正在尝试将其改编为greasemonkey的用户脚本,首先,我的脚本不会通过网站安装,其次,当我使用“新用户脚本”在本地安装时它似乎什么也不做,控制台也没有任何记录,以下是我的代码:

// // ==UserScript==
// @name    Cerberus Time-since Row Colouring
// @author  David Duke, Luke Mulholland-Helme-Kelsall 
// @description Looks for ABBR tags and their title parameter, and then calculates the time difference between Now and the timestamps. The parent table row then has an appropraite CSS class added to it based on the time difference calculated.
// @include http://{removed url}/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require     http://www.datejs.com/build/date.js

// ==/UserScript==
$(document).ready(function(){
$('abbr').each(function(index){
    var _then = Date.parse($(this).attr('title'));
    var _now = new Date().getTime();
    _then = _then.getTime();            
    var a_minute = 60000;
    if(_now < _then + (a_minute*30)){
        $(this).parent(tr).css("background-color","green");
    } else if(_now < _then + (a_minute*60)){
        $(this).parent(tr).css("background-color","yellow");
    } else {
        $(this).parent(tr).css("background-color","red");
    }
    console.log("title:" + $(this).attr('title') + ",_then:"+_then+",_now:"+_now);
});
});
/==UserScript==
//@name Cerberus自行着色以来的时间
//@作者大卫·杜克、卢克·穆霍兰德·赫尔姆·凯尔萨尔
//@description查找ABBR标记及其title参数,然后计算现在与时间戳之间的时间差。然后,父表行将根据计算的时差向其添加一个appropraite CSS类。
//@include http://{removed url}/*
//@需要http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
//@需要http://www.datejs.com/build/date.js
//==/UserScript==
$(文档).ready(函数(){
$('abbr')。每个(函数(索引){
var\u then=Date.parse($(this.attr('title'));
var_now=new Date().getTime();
_然后=_then.getTime();
var a_分钟=60000;
如果(现在<然后+(一分钟*30)){
$(this.parent(tr.css)(“背景色”、“绿色”);
}否则如果(现在<然后+(一分钟*60)){
$(this.parent(tr.css)(“背景色”、“黄色”);
}否则{
$(this.parent(tr.css)(“背景色”,“红色”);
}
log(“title:++$(this).attr('title')+”,\u-then:++\u-then+”,\u-now:++\u-now);
});
});

这方面的任何帮助都会很好,因为我正在绞尽脑汁,可能与@require部分有关,但从我在谷歌上找到的内容来看,这应该足以使用这些脚本中的函数。

你的问题是,你已经注释掉了,应该是什么,GM scipt声明

而不是

// // ==UserScript==
// @name    Cerberus Time-since Row Colouring
// @author  David Duke, Luke Mulholland-Helme-Kelsall 
// @description Looks for ABBR tags and their title parameter, and then calculates the time difference between Now and the timestamps. The parent table row then has an appropraite CSS class added to it based on the time difference calculated.
// @include http://{removed url}/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require     http://www.datejs.com/build/date.js

// ==/UserScript==
使用:

这将解决脚本检测或安装问题

// @include http://{removed url}/*
如果您的实际脚本与此匹配,则可能是问题所在。。。我在某个地方读到缺少空格会导致问题

试试这个:

// @include     http://{removed url}/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js

一切的版本?查看脚本的目录,
在{FF profile folder}/gmu scripts
下。jquery.min.js和date.js是否存在?如果是这样的话,requires工作正常。所有新创建的userscript都对该块进行了注释,应该是这样的-除了第一个,其中==userscript==被注释了两次。。。。。。。@include行中缺少空格可能会导致问题。
// @include     http://{removed url}/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js