Closed Bug 1710565 Opened 3 years ago Closed 3 years ago

First extension creation tutorial not working

Categories

(WebExtensions :: Untriaged, defect)

Firefox 88
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1672859

People

(Reporter: navinipe, Unassigned)

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0

Steps to reproduce:

I tried the tutorial on this page: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension.
Firefox 88, 64 bit run on Ubuntu 20.10 (Groovy Gorilla).
Followed all the instructions but even after loading the addon into Firefox and visiting a mozilla.org site, the red border didn't appear.

This was the code used in manifest.json:
{

"manifest_version": 2,
"name": "Borderify",
"version": "1.0",

"description": "Adds a red border to all webpages matching wumo.com",

"icons": {
"48": "icons/border-48.png",
"96": "icons/border-96.png"
},

"content_scripts": [
{
"matches": ["://.mozilla.org/*"],
"js": ["borderify.js"]
}
]

}

and this was the code used in borderify.js:
document.body.style.border = "20px solid red";

Later I modified borderify.js to this:
alert("Hello! I am an alert box!!");
document.body.style.border = "20px solid red";

Actual results:

Nothing happened.

Expected results:

A red border was supposed to appear when a mozilla.org website was opened. I even modified the "://.mozilla.org/" string to "://xkcd.com/" and "://wumo.com/*" and a few other sites and then reloaded the extension. But not even the javascript alert box appeared when I visited the corresponding websites.

Please provide a working tutorial.

The Bugbug bot thinks this bug should belong to the 'WebExtensions::Untriaged' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Product: Firefox → WebExtensions

Hello nav,

I could not reproduce the issue you are having (i.e. the add-on created through the tutorial does not work) , using the tutorial from https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension on the latest Nightly (90.0a1/20210512174859), Beta (89.0b11/20210511190154) and Release (88.0.1/20210504152106) under Windows 10 x64 and Ubuntu 16.04 LTS.

The instructions provided in the tutorial are fine and the add-on created through it works as intended. See the attached screenshots for more details.

I did notice though that in the manifest.json code you pasted in the description there is a mistake. More specifically, the line "matches": ["://.mozilla.org/*"], from the content_scripts section is missing some * and thus the matching condition is not fulfilled and the border is not applied to the page.

The correct line should include several * placeholders like this "matches": ["*://*.mozilla.org/*"],

Please try again with the corrected line and let me know of the results. Thank you !

Flags: needinfo?(navinipe)
Attached image 2021-05-13_11h38_30.png
Attached image 2021-05-13_11h40_32.png
Attached image 2021-05-13_11h41_30.png

Thanks for checking, Alex. I have a few things to say:

  1. The error was not because of ["://.mozilla.org/"]. I had initially copy-pasted the correct string ["://.mozilla.org/"]. It ended up as //.mozilla after I tried xkcd etc.
  2. It's working now, because after you said it's working at your end, I just checked to see if it was because of Firefox Settings > Privacy and security > History > Never remember history. And sure enough, that was the problem. When I changed it to "Remember History" and restarted firefox, the red border appears.
  3. So if it does not work in (what I assume was) a constant incognito mode that I had enabled, perhaps either the tutorial could mention this, so that users could disable incognito mode, or perhaps Firefox could display some notification about allowing the addon to run. It also helps to know what kind of addon features won't work in incognito mode.

I had started learning to create addons to get rid of the annoying cookie banner that shows up on each of the StackExchange websites on every tab I opened. So since I and perhaps many others would be using the browser in permanent incognito mode, it'd help if addons could be made to work in incognito mode too.

Thanks again, for taking the time to check this. Hope it was of help.

Flags: needinfo?(navinipe)

Apologies for the confusion. This should be resolved once bug 1672859 is fixed.

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
See Also: → 1672859
See Also: 1672859
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: