jquery和greasemonkey齐上阵

jquery写起来真的很简单,连我这刚接触jquery不久的新人都能很快用它码出大段的javascript。唯一的坏处是代码里充斥了大量的$。既然写javascript如此简单,那么用jquery+greasemonkey插件同时干活怎么样呢?

这里是一段提醒jquery已经载入的脚本,为了避免和页面上原有的代码冲突,得运行$.noConflict().

CODE:
  1. // All your GM code must be inside this function
  2. function letsJQuery() {
  3. //make sure there is no conflict between jQuery and other libraries
  4. $.noConflict()
  5. //notify that jQuery is running...
  6.   $('<div>jQuery is running!</div>')
  7.     .css({padding: '10px', background: '#ffc', position: 'absolute',top: '0', width: '100%'})
  8.     .prependTo('body')
  9.     .fadeIn('fast')
  10.     .animate({opacity: 1.0}, 300)
  11.     .fadeOut('fast', function() {
  12.       $(this).remove();
  13.     });
  14. //start custom jQuery scripting.
  15. }

引入jquery.js只用简单的一行,感谢greasemonkey!

CODE:
  1. GM_JQ.src = 'http://jquery.com/src/jquery-latest.js';

原文:Have Your jQuery Fun on Any Site with Greasemonkey

作者: volcano 发表于7月 4, 2007 at 6:27 am

版权信息: 可以任意转载, 转载时请务必以超链接形式标明文章原始出处作者信息及此声明

Tags: ,,

4 条评论 »

  1. 肥大 于 2007-08-17 @ 20:52:07 留言

    推荐一款让Eclipse支持jquery的插件
    http://www.langtags.com/jquerywtp/index.html

  2. 六六 于 2007-09-24 @ 14:29:32 留言

    楼上的网站是抄袭人家http://www.java2s.com 的内容,
    想要看好东东,直接去www.java2s.com 就好了

  3. volcano 于 2007-09-24 @ 17:26:09 留言

    六六推荐的站点貌似有些参考价值

  4. 六六 于 2007-09-27 @ 12:11:54 留言

    当然,WWW.JAVA2S.COM 是个人最喜欢的代码网站

RSS 为此帖反馈评论 · 反向跟踪 网站

留条评论