Correct userScripts / userScripts_legacy index#579
Merged
Conversation
The MV2-specific userScripts example is currently associated with the "userScripts.register" API. While this is the correct API name, the MDN documentation is actually at `userScripts_legacy/register`. To make sure that the example is rendered in the right location, change "userScripts" to "userScripts_legacy". ... and for completeness also add `runtime.onMessage` to the MV3 example, since that example uses this API.
rebloor
approved these changes
Mar 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The MV2-specific userScripts example is currently associated with the "userScripts.register" API. While this is the correct API name, the MDN documentation is actually at
userScripts_legacy/register.To make sure that the example is rendered in the right location, change "userScripts" to "userScripts_legacy".
... and for completeness also add
runtime.onMessageto the MV3 example, since that example uses this API.Motivation
The user-script-register example currently appears at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/userScripts/register#example_extensions, but it should not. Instead, it should be at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/userScripts_legacy/register
Additional details
With this patch, the example will be moved to the correct location, as desired.
The index of all examples, at https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Examples,
would showuserScripts_legacy.registerinstead ofuserScripts.register (legacy). This is a mild issue, and I plan to address that by submitting a patch to the logic at https://github.com/mdn/yari/blob/79c4a5ef6b2807e52b851ec4b54f0def71b0f319/kumascript/macros/WebExtAllExamples.ejs#L48I tested locally, and the link is rendered as
userScripts.register() (Legacy), as desired, as explained at mdn/yari#12677 (comment).Related issues and pull requests
This is a follow-up to mdn/content#38073 and #576.