jquery和greasemonkey齐上阵
jquery写起来真的很简单,连我这刚接触jquery不久的新人都能很快用它码出大段的javascript。唯一的坏处是代码里充斥了大量的$。既然写javascript如此简单,那么用jquery+greasemonkey插件同时干活怎么样呢?
这里是一段提醒jquery已经载入的脚本,为了避免和页面上原有的代码冲突,得运行$.noConflict().
// All your GM code must be inside this function
function letsJQuery() {
//make sure there is no conflict between jQuery and other libraries
$.noConflict()
//notify that jQuery is running...
$('<div>jQuery is running!</div>')
.css({padding: '10px', background: '#ffc', position: 'absolute',top: '0', width: '100%'})
.prependTo('body')
.fadeIn('fast')
.animate({opacity: 1.0}, 300)
.fadeOut('fast', function() {
$(this).remove();
});
//start custom jQuery scripting.
}
引入jquery.js只用简单的一行,感谢greasemonkey!
GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';
载入jquery的脚本
var GM_JQ = document.createElement('script');
GM_JQ.src = 'http://code.jquery.com/jquery-latest.js';
GM_JQ.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(GM_JQ);
原文:Have Your jQuery Fun on Any Site with Greasemonkey
作者: Volcano 发表于July 4, 2007 at 6:27 am
肥大 于 2007-08-17 @ 20:52:07 留言 :
推荐一款让Eclipse支持jquery的插件
http://www.langtags.com/jquerywtp/index.html
六六 于 2007-09-24 @ 14:29:32 留言 :
楼上的网站是抄袭人家http://www.java2s.com 的内容,
想要看好东东,直接去www.java2s.com 就好了
volcano 于 2007-09-24 @ 17:26:09 留言 :
六六推荐的站点貌似有些参考价值
六六 于 2007-09-27 @ 12:11:54 留言 :
当然,WWW.JAVA2S.COM 是个人最喜欢的代码网站