0

好的,所以我创建了一个小脚本,我想根据页面上某些标签中的数据更改表格行的格式,离线脚本工作正常,但我正在尝试调整它以作为用户脚本提供油脂猴,首先我的脚本不会通过站点安装,其次当我使用“新用户脚本”在本地安装时,它似乎什么也没做,控制台也没有记录任何内容,这是我的代码:

// // ==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);
});
});

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

4

2 回答 2

0
// @include http://{removed url}/*

如果您的实际脚本与此匹配,则可能是问题所在...我在某处读到缺少空格会导致问题...

尝试这个:

// @include     http://{removed url}/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
于 2013-07-26T18:35:13.593 回答
-1

您的问题是,您已经注释掉了应该是什么,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==

利用:

// ==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==

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

于 2012-06-15T22:54:08.580 回答