You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MDN get started tutorial examples to manifest V3 (#608)
* MDN get started tutorial examples to manifest V3
* Migrate to Scripting API
* Updated to readmes and code comments
* Apply suggestions to readmes from review
Co-authored-by: Simeon Vincent <svincent@gmail.com>
* Convert choose_beast.js to async
* Apply suggestions from review
Co-authored-by: Simeon Vincent <svincent@gmail.com>
* Updated illustrated API list for beastify
* Apply suggestions from review
Co-authored-by: Rob Wu <rob@robwu.nl>
---------
Co-authored-by: Simeon Vincent <svincent@gmail.com>
Co-authored-by: Rob Wu <rob@robwu.nl>
This extension used a tootlbar button to enable the section of beast that replaces the content of the active web page.
4
+
3
5
## What it does ##
4
6
5
7
The extension includes:
6
8
7
-
*a browser action with a popup including HTML, CSS, and JS
8
-
*a content script
9
-
*three images, each of a different beast, packaged as web accessible resources
9
+
*An action with a popup that includes HTML, CSS, and JavaScript.
10
+
*A content script.
11
+
*Three images, each of a beast, packaged as web accessible resources.
10
12
11
-
When the user clicks the browser action button, the popup is shown, enabling
12
-
the user to choose one of three beasts.
13
+
When the user clicks the action (toolbar button), the extension's popup opens, enabling the user to choose one of three beasts.
13
14
14
-
When it is shown, the popup injects a content script into the current page.
15
+
When opened, the popup injects a content script into the active page.
15
16
16
-
When the user chooses a beast, the extension sends the content script a message containing
17
-
the name of the chosen beast.
17
+
When the user chooses a beast, the extension sends the content script a message containing the name of the chosen beast.
18
18
19
-
When the content script receives this message, it replaces the current page
20
-
content with an image of the chosen beast.
19
+
When the content script receives this message, it replaces the active page content with an image of the chosen beast.
21
20
22
-
When the user clicks the reset button, the page reloads, and reverts to its original form.
21
+
When the user clicks the reset button, the page reloads and reverts to its original form.
23
22
24
23
Note that:
25
24
26
-
*if the user reloads the tab, or switches tabs, while the popup is open, then the popup won't be able to beastify the page any more (because the content script was injected into the original tab).
25
+
*If the user reloads the tab, or switches tabs, while the popup is open, then the popup can't beastify the page (because the content script was injected into the original tab).
27
26
28
-
*by default [`tabs.executeScript()`](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/tabs/executeScript) injects the script only when the web page and its resources have finished loading. This means that clicks in the popup will have no effect until the page has finished loading.
27
+
*By default,[`scripting.executeScript()`](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/scripting/executeScript) injects the script only when the web page and its resources have finished loading. This means that clicks in the popup have no effect until the page has finished loading.
29
28
30
-
*it's not possible to inject content scripts into certain pages, including privileged browser pages like "about:debugging" and the [addons.mozilla.org](https://addons.mozilla.org/) website. If the user clicks the beastify icon when such a page is loaded into the active tab, the popup displays an error message.
29
+
*Browsers don't allow extensions to inject content scripts into specific pages. In Firefox, this includes privileged browser pages, such as "about:debugging", and the [addons.mozilla.org](https://addons.mozilla.org/) website. In Chrome, this includes internal pages, such as `chrome://extensions`, and the [chromewebstore.google.com](https://chromewebstore.google.com/) website. If the user clicks the beastify icon on one of these pages, the popup displays an error message.
31
30
32
31
## What it shows ##
33
32
34
-
* write a browser action with a popup
35
-
* how to have different browser_action images based upon the theme
36
-
* give the popup style and behavior using CSS and JS
37
-
* inject a content script programmatically using `tabs.executeScript()`
38
-
* send a message from the main extension to a content script
39
-
* use web accessible resources to enable web pages to load packaged content
40
-
* reload web pages
33
+
In this example, you see how to:
34
+
35
+
* Write an action (toolbar button) with a popup.
36
+
* Display action (toolbar button) icons based on the browser theme.
37
+
* Give a popup style and behavior using CSS and JavaScript.
38
+
* Inject a content script programmatically using `scripting.executeScript()`.
39
+
* Send a message from the main extension to a content script.
40
+
* Use `web_accessible_resources` to enable web pages to load packaged content.
Copy file name to clipboardExpand all lines: beastify/manifest.json
+17-4Lines changed: 17 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
{
2
2
3
3
"description": "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. See https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Examples#beastify",
**This add-on injects JavaScript into web pages. The `addons.mozilla.org` domain disallows this operation, so this add-on will not work properly when it's run on pages in the `addons.mozilla.org` domain.**
3
+
This add-on injects JavaScript into mozilla.org web pages.
4
4
5
5
## What it does
6
6
7
-
This extension just includes:
7
+
This extension includes a content script, "borderify.js", that is injected into any pages
8
+
under "mozilla.org/" or any of its subdomains.
8
9
9
-
* a content script, "borderify.js", that is injected into any pages
10
-
under "mozilla.org/" or any of its subdomains
10
+
**The `addons.mozilla.org` domain doesn't allow scripts to be injected into its pages. Therefore, this extension doesn't work on pages in the `addons.mozilla.org` domain.**
11
11
12
12
The content script draws a border around the document.body.
13
13
14
14
## What it shows
15
15
16
-
*how to inject content scripts declaratively using manifest.json
16
+
From this example, you see how to inject content scripts declaratively using manifest.json.
Copy file name to clipboardExpand all lines: borderify/manifest.json
+10-1Lines changed: 10 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,23 @@
1
1
{
2
2
3
3
"description": "Adds a solid red border to all webpages matching mozilla.org. See https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Examples#borderify",
Copy file name to clipboardExpand all lines: examples.json
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -31,12 +31,12 @@
31
31
{
32
32
"description": "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.",
0 commit comments