greasemonkey_Firefox中Greasemonkey用户脚本的初学者指南

greasemonkey

greasemonkey

Everybody knows that Firefox has add-ons for virtually everything, but if you don’t want to bloat your installation you’ve always got the option of Greasemonkey scripts instead. Here’s a quick primer on how to use them.

每个人都知道Firefox几乎可以包含所有内容的附件,但是如果您不想膨胀安装,则始终可以选择Greasemonkey脚本。 这是如何使用它们的快速入门。

Getting Started with User Scripts

用户脚本入门

Once you have Greasemonkey installed, managing the extension is really easy. Left click on the status bar icon to turn the extension on/off and right click to access the context menu shown here.

一旦安装了Greasemonkey,就很容易管理扩展。 左键单击状态栏图标以打开/关闭扩展名,右键单击以访问此处显示的上下文菜单。

greasemonkey-01

Whether you use the Options button in the Add-ons Manager Window or the context menu shown above, both will bring up the Manage User Scripts dialog. At the moment you have a nice clean slate to work with… time to get some scripts added in.

无论您使用“附件管理器”窗口中的“选项”按钮还是上面显示的上下文菜单,两者都将弹出“管理用户脚本”对话框。 目前,您的工作情况不错,可以添加一些脚本。

greasemonkey-02

The majority of user scripts can be found at two different sites, the first being appropriately named userscripts.org, and you can either browse by tag or search for a script.

大多数用户脚本可以在两个不同的站点上找到,第一个站点的名称适当地为userscripts.org,您可以按标记浏览或搜索脚本。

greasemonkey-03

As you can see here your search for a particular type of script can be quickly narrowed down based on category. There is definitely a lot to choose from.

如您所见,可以根据类别快速缩小对特定类型脚本的搜索范围。 绝对有很多选择。

greasemonkey-04

For our example we focused on the “textarea” tag. There were 62 scripts available but we quickly found what we were looking for on the first page.

对于我们的示例,我们重点关注“ textarea”标签。 有62个可用的脚本,但我们很快在第一页上找到了所需的内容。

greasemonkey-05

Installing, Managing, & Using Your Scripts

安装,管理和使用脚本

When you find a script that you want to install visit the script’s homepage and click on the “Install” button.

当您找到要安装的脚本时,请访问该脚本的主页,然后单击“安装”按钮。

Note: Link for this script provided below.

注意:下面提供了此脚本的链接。

greasemonkey-06

Once you have clicked on the Install button, Greasemonkey will open up the following installation window. You will be able to view:

单击“安装”按钮后,Greasemonkey将打开以下安装窗口。 您将能够查看:

  • A summary of what the script does

    脚本功能摘要
  • A list of websites that the script is supposed to function on (our example is set for all)

    该脚本应在其上运行的网站列表(我们的示例已针对所有网站设置)
  • View the script source if desired

    如果需要,查看脚本源
  • Make a final decision on whether to install the script or cancel the process

    关于是否要安装脚本或取消该过程做出最终决定
greasemonkey-07

Right-clicking on our status bar icon shows our new script listed and active.

右键单击状态栏图标可显示列出的新脚本并处于活动状态。

greasemonkey-08

Reopening the Manage User Scripts window shows:

重新打开“管理用户脚本”窗口,显示:

  • Our new script listed in the column on the left

    我们的新脚本在左侧列中列出
  • The websites/pages included

    包含的网站/页面
  • An option to disable the script (can also be done in the context menu)

    禁用脚本的选项(也可以在上下文菜单中完成)
  • The ability to edit the script

    编辑脚本的能力
  • The ability to uninstall the script

    卸载脚本的能力
greasemonkey-09

If you choose to edit the script you will be asked to browse for and select a default text editor of your choice (first time only). Once you have selected a text editor you can make any changes desired to the script.

如果您选择编辑脚本,将要求您浏览并选择一个默认的文本编辑器(仅限第一次)。 选择文本编辑器后,您可以对脚本进行所需的任何更改。

greasemonkey-10

We decided to test our new user script on the site. Going to the comment box at the bottom we could easily resize the window as desired.

我们决定在站点上测试我们的新用户脚本。 转到底部的评论框,我们可以轻松地根据需要调整窗口的大小。

greasemonkey-11

The Comment box definitely got a lot bigger.

评论框肯定更大了。

greasemonkey-12

Conclusion

结论

If you prefer to keep the number of extensions to a minimum in your Firefox installation then Greasemonkey and the Userscripts website can easily provide that extra functionality without the bloat. For added auto website script detection goodness see our article on Greasefire.

如果您希望在Firefox安装中将扩展名的数量保持在最低水平,那么Greasemonkey和Userscripts网站可以轻松提供该额外功能,而不会引起麻烦。 有关自动网站脚本检测的更多信息,请参阅有关Greasefire的文章。

Note: See our article here for specialized How-To Geek User Style Scripts that can be added to Greasemonkey.

注意: 有关可添加到Greasemonkey的专门的How-To Geek用户样式脚本, 请参见 此处 的文章

Links

链接

Download the Greasemonkey Extension (Mozilla Add-ons)

下载Greasemonkey扩展(Mozilla附加组件)

Install the Textarea & Input Resize User Script

安装Textarea和输入调整大小的用户脚本

Visit the Userscripts.org Website

访问Userscripts.org网站

Visit the Userstyles.org Website

访问Userstyles.org网站

翻译自: https://www.howtogeek.com/howto/16470/replace-extensions-with-user-scripts-in-firefox/

greasemonkey

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
通过使用少量的JavaScript脚本,自定义网页显示方式或表现方式。Greasemonkey是Mozilla Firefox的一个附加组件。它让用户安装一些脚本使大部分HTML为主的网页于用户端直接改变得更方便易用。随着Greasemonkey脚本常驻于浏览器,每次随着目的网页打开而自动做修改,使得运行脚本用户印象深刻地享受其固定便利性。 技术明细: 大部分Greasemonkey用户脚本都是自行撰写,使用对某网站专用的JavaScript代码,通过文档对象模型(DOM)接口对网页内容做操作。userscripts.org维护了个Greasemonkey数据库。该数据库描述哪个网址网页对应到哪个脚本。当用户加载匹配的网页,Greasemonkey便调用相关的脚本,而该脚本便根据脚本内容改变网页的内容。Greasemonkey脚本亦能通过非网域绑定的XMLHTTP要求来查询外部HTTP资源。Greasemonkey亦遵循某用户名.user.js的格式,这让当该特定用户拜访时Greasemonkey可自动侦测并提供安装选项。除了JavaScript代码,Greasemonkey脚本包括有限可选用后数据集。该后数据集描述了脚本名称、脚本描述、网址用来区分同名脚本的地址空间、以及原本该脚本为哪些网址撰写的列表。Greasefire扩展:同Greasemonkey扩展配合使用,自动显示在userscripts.org的脚本是否存在可以在当前正在浏览网站上使用的脚本,如果存在Greasemonkey的猴头图标背景就会变为彩色的。右键点击猴头图标,最上面一行就是打开当前网站可用脚本列表的选项。Platypus(platypus.mozdev.org)附加组件可让用户可以编辑网页(删除或者移动某碍眼的部分)。Platypus随后将结果存成常驻的Greasemonkey脚本。 典型的脚本用户群已发展大量的脚本,以下是其的一些应用:调整Gmail让Google Reader内嵌,因而提供RSS新闻订阅的选项。当联机浏览某本书时同时显示对手网站同本书价钱。去除来自某些站的广告,包括弹出视窗与Google文字广告。改变网页的版面,包括原本该网页作者未考虑到的元素大小与浏览器画面大小。自动完成窗体。浏览某些布告栏网站自动过滤特定的发帖人。增删网页上的某些功能。让用户从某些视频站点如Google Video以及YouTube存下FLV视频文件。从现行网页找寻任何RSS新闻订阅,并将它们显示在可扩展、漂浮于网页上的皮肤里。突破百度贴吧对言论内容的管制,辅助发表繁体汉字及不受贴吧服务器支持的字符,或者将文字转换为图片发表。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值