![]() | This is a documentation subpage for Template:Userscript. It may contain usage information, categories and other content that is not part of the original template page. |
![]() | This template employs intricate features of template syntax.
You are encouraged to familiarise yourself with its setup and parser functions before editing the template. If your edit causes unexpected problems, please undo it quickly, as this template may appear on a large number of pages. You can conduct experiments, and should test all major changes, in either this template's sandbox, the general template sandbox, or your user space before changing anything here. |
This template is used to create userscript listings, primarily for use at Wikipedia:User scripts, but it can be used on any page.
Usage
{{userscript |code= [.js address] |name= [script name] |doc= [documentation page address] }}
The name will be linked to the documentation page, and separate "(source)" text will link to the code page.
- All parameters are optional. The template will attempt to fill in defaults for the missing information. Enter any explicit parameters to override defaults.
- Check to make sure the links are accurate after placing this template! If any defaults are inaccurate, enter the necessary parameters explicitly.
- If you end up leaving the template with no "(source)" link produced, make sure your documentation page includes complete installation instructions, along with any necessary code page addresses.
- You can make up any name for the
|name
parameter. It is just for display purposes, and does not need to match any actual page address.
Logic details
- The template will add .js to the documentation page name to get a default code page, or remove .js from the code page name to get a default documentation page.
- Entering
|code=User:TheDJ/Sharebox.js
will look for a page named User:TheDJ/Sharebox, and if found, will be linked as the documentation page. - Entering
|doc=User:TheDJ/Sharebox
will look for a page named User:TheDJ/Sharebox.js, and if found, will be linked as the code page.
- Entering
- If the default pages don't actually exist, they won't be linked (so defaults shouldn't produce red links).
- If no name is entered, a default name will be produced from the code or doc page name (whichever is entered).
Examples
All parameters specified: {{userscript|name=sharebox!!!!!|code=User:TheDJ/sharebox.js|doc=User:TheDJ/sharebox}}
- Produces: sharebox!!!!![1] (source)
Name + doc specified: {{userscript|name=sharebox!!!!!|doc=User:TheDJ/sharebox}}
- Produces: sharebox!!!!![2] (source)
Code only: {{userscript|code=User:TheDJ/sharebox.js}}
Doc only: {{userscript|doc=User:TheDJ/sharebox}}
Additional parameter
This template enables an automatic installation link for editors who use automatic installer scripts like User:Equazcion/ScriptInstaller. If you have reason to disable automatic installation for a particular script (eg. because it requires more than just the usual importScript line), add the following parameter:
|noautoinstall=yes
- ^ Copy the following code, edit your user JavaScript, then paste:
{{subst:lusc|1=User:TheDJ/sharebox.js}}
- ^ Copy the following code, edit your user JavaScript, then paste:
{{subst:lusc|1= User:TheDJ/sharebox.js}}
- ^ Copy the following code, edit your user JavaScript, then paste:
{{subst:lusc|1=User:TheDJ/sharebox.js}}
- ^ Copy the following code, edit your user JavaScript, then paste:
{{subst:lusc|1= User:TheDJ/sharebox.js}}