English 中文(简体)
Grease 猴子脚本不运行 - 第一次脚本尝试
原标题:Grease Monkey Script doesn t run - first script attempt

Ok so I have created a little 脚本, 我想根据页面上某些标记中的数据来修改表格行的格式, 脱线脚本效果很好, 但我尝试调整它, 以提供一个油墨键的用户标本, 首先我的脚本不会通过网站安装, 其次当我使用“ 新用户脚本” 在本地安装时, 它似乎什么都不做, 也没有记录到主控台, 我的代码在这里 :

// // ==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部分有关, 但从我对谷歌的看法来看, 应该足以使用这些脚本中的功能。

问题回答
// @include http://{removed url}/*

如果你的实际脚本符合,那可能就是问题...

尝试此 :

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

你的问题是,你已经评论了, 什么是应该是什么, GM Scopt 声明。

取代

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

这样就能解决你的脚本探测或安装问题





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签