文章标签 ‘Greasemonkey’

    如果你在使用Firefox,很幸运你可以通过Greasemonkey插件使用Firefox支持UserScript,也就是在浏览网站页面时执行自己的javascript从而实现你想要的功能,比如在浏览某个广告比较多的网站去除广告。Greasemonkey可以方便实现你脚本效果。我们将一步步使用Greasemonkey写我们的第一个UserScript Hello World,让我们开始吧   首先我们搭建支持UserScript的Firefox环境,下载Greasemonkey https://addons.mozilla.org/addon/748 点击安装,重启Firefox,此时Firefox右下角有一个 ,你的Firefox已经支持UserScript了。接着我们写一个Hello World测试。 用户记事本新建立一个文本文件在里面输入 alert(‘Hello World.’); 保存,重命名文件为 helloworld.user.js(Greasemonkey自动识别xxxxx.user.js为UserScript文件)               使用Firefox打开helloworld.user.js文件,跳出 点击Install安装,Firefox右下角会提示helloworld安装成功的信息 这个时候使用Firefox浏览网站发现已经有Hello World的欢迎信息 是不是很简单。 我们通过Tools->GreaseMonkey->Manage User Scripts来管理UserScript 通过Included Pages和Excluded Pages来控制UserScripts执行的范围。 如果我们只想在打开www.google.com的时候显示提示信息 那么我们Included Pages * 改为 http://www.google.com/* 这里正则匹配 相反如果不想在www.radys.cn下显示提示信息,就在Excluded Pages里添加 http://www.radys.cn   我们通过 控制、编辑、删除UserScripts。   到这里我们的第一个UserScripts Hello World完成。如果你有什么想法请留言或发Email给我.

2010年5月5日23:34 | 1 条评论
分类: 前端页面