Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Example WebExtensions

为了解如何开发WebExtensions,我们维护了一个简单的WebExtensions的代码库在 https://github.com/mdn/webextensions-examples. 本文介绍了代码仓库中的扩展案例.

这些案例运行在 Firefox Nightly: 一些运行在老版本的 Firefox, 请检查 manifest.json 文件中的 strict_min_version 键.

代码仓库可能不定期更新,因此扩展在浏览器中可能不正常工作,请注意反馈。

推荐使用 about:debugging 安装并运行, 该功能在 Firefox 45 中添加. 通过这种方式,你可以直接从目录加载附加组件,所以不需要压缩打包或签名步骤。

如果你想对代码仓库贡献,给我们发送pull申请!


beastify

https://github.com/mdn/webextensions-examples/tree/master/beastify

Adds a browser action icon to the toolbar. Click the button to choose a beast. The active tab's body content is then replaced with a picture of the chosen beast.

Manifest keys

JavaScript modules


Bookmark it!

https://github.com/mdn/webextensions-examples/tree/master/bookmark-it

A simple bookmark button

Manifest keys

JavaScript modules


borderify

https://github.com/mdn/webextensions-examples/tree/master/borderify

Adds a solid red border to all webpages matching mozilla.org.

Manifest keys


chill-out

https://github.com/mdn/webextensions-examples/tree/master/chill-out

Show a page action after a period of inactivity. Show cat gifs when the page action is clicked.

Manifest keys

JavaScript modules


commands

https://github.com/mdn/webextensions-examples/tree/master/commands

Press Ctrl+Shift+Y to send an event (Command+Shift+Y on a Mac).

Manifest keys

JavaScript modules


https://github.com/mdn/webextensions-examples/tree/master/cookie-bg-picker

Allows the user to customize the background color and tiled pattern on sites the visit, and also saves their preferences via a cookie, reapplying them whenever they revisit a site they previously customized.

Manifest keys

JavaScript modules


context-menu-demo

https://github.com/mdn/webextensions-examples/tree/master/context-menu-demo

Demonstrates various features of the contextMenus API.

Manifest keys

JavaScript modules


favourite-colour

https://github.com/mdn/webextensions-examples/tree/master/favourite-colour

An example options ui

Manifest keys

JavaScript modules


history-deleter

https://github.com/mdn/webextensions-examples/tree/master/history-deleter

History API demo: deletes history items for a given domain

Manifest keys

JavaScript modules


latest-download

https://github.com/mdn/webextensions-examples/tree/master/latest-download

Shows the last downloaded item, and lets you open or delete it.

Manifest keys

JavaScript modules


https://github.com/mdn/webextensions-examples/tree/master/notify-link-clicks-i18n

Shows a notification when the user clicks on links.

Manifest keys

JavaScript modules


open-my-page-button

https://github.com/mdn/webextensions-examples/tree/master/open-my-page-button

Adds browser action icon to toolbar to open packaged web page.

Manifest keys

JavaScript modules


page-to-extension-messaging

https://github.com/mdn/webextensions-examples/tree/master/page-to-extension-messaging

Visit https://mdn.github.io/webextensions-examples/content-script-page-script-messaging.html for the demo.

Manifest keys


quicknote

https://github.com/mdn/webextensions-examples/tree/master/quicknote

Allows the user to make quick notes by clicking a button and entering text into the resulting popup. The notes are saved in storage.

Manifest keys

JavaScript modules


tabs-tabs-tabs

https://github.com/mdn/webextensions-examples/tree/master/tabs-tabs-tabs

A list of methods you can perform on a tab.

Manifest keys

JavaScript modules


user-agent-rewriter

https://github.com/mdn/webextensions-examples/tree/master/user-agent-rewriter

Adds browser action icon to toolbar to choose user agent string from popup menu.

Manifest keys

JavaScript modules

文档标签和贡献者

 此页面的贡献者: GrayLight
 最后编辑者: GrayLight,