Jump to content

Template:Userscript and Template:Userscript/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
Replace edit link (see talk)
 
comments
 
Line 1: Line 1:
<noinclude>{{pp-template|small=yes}}</noinclude><includeonly>{{#if: {{{doc|}}}<!--
<includeonly><!--

-->|[[{{{doc}}}|{{{name|{{SUBPAGENAME:{{#invoke: String|replace|source={{{code|{{{doc|}}}.js}}}|pattern=.js|replace=}}}}}}}]]<!--
https://en.wikipedia.org/wiki/Template:Userscript
-->|{{#ifexist: {{#invoke: String|replace|source= {{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | <!--nothing--> }} }}}|pattern= .js |replace= }}<!--

-->| [[{{#invoke: String|replace|source= {{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | <!--nothing--> }} }}}|pattern=.js|replace=}}|{{{name|{{{name| {{SUBPAGENAME:{{#invoke: String|replace|source= {{{code|{{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js |<!--nothing-->}}}}}|pattern=.js|replace=}}<!-- -->}}}}}<!-- -->}}}]]<!--
usage: {{userscript |code= [.js address] |name= [script name] |doc= [documentation page address] }}
-->|{{{name|{{{name|{{SUBPAGENAME: {{#invoke: String|replace|source= {{{code|{{#ifexist:{{{doc|}}}.js|{{{doc|}}}.js|<!--nothing-->}}}}}|pattern= .js |replace= }} }} }}} }}} }} }}<!--

-- Begin generation of ref tag

-->{{#if: {{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | <!--nothing--> }} }}} |{{#ifeq: {{{noautoinstall}}} | yes | <!--nothing--> | {{#ifeq: {{{noref|}}} | yes | <!-- nothing --> | {{#tag:ref|Copy the following code, [[Special:EditPage/Special:MyPage/common.js|'''edit your user JavaScript''']], then paste:<br /><code>{{subst:{{#if:{{str endswith|{{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | <!--nothing--> }} }}}|.css}}|luss|lusc}}|1={{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js| <!--nothing--> }}}}}{{#ifeq:{{{backlink|}}}|||{{!}}2{{=}}{{{backlink}}} }}}} </code> }} }} |<!--nothing-->}} }} <!--

-- End generation of ref tag, begin generation of "(source)"
-->{{#if: {{{doc|}}} |<!-- if {{{doc|}}} (documentation page address) is not null
-->{{#if: {{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | <!--nothing--> }} }}} | <small>([[{{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | <!--nothing--> }} }}}|source]])</small> |<!--nothing-->}}<!--
_____-->[[<!-- open link
-- End generation of "(source)", begin generation of span for automated installer scripts
_____-->{{{doc}}} | <!-- link location
-->{{#ifeq: {{{noautoinstall}}} | yes |<!-- nothing -->|<span id="{{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | <!--nothing--> }} }}}" class="scriptInstallerLink"<!--the class "scriptInstallerLink" supports automated installers, do not remove-->></span>}}{{#if:{{{desc|}}}|{{sp}}– {{{desc|}}}}}</includeonly><noinclude>{{doc}}</noinclude>
_____-->{{{name | <!-- {{{name}}} is script name
_____-->{{SUBPAGENAME: <!-- if {{{name}}} is null
__________-->{{#invoke: String| replace| source= {{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | {{{doc|}}}.js }} }}} | pattern= .js | replace= }} <!-- {{{code}}} is .js address. Gets rid of .js extension.
_____-->}} <!-- close subpagename
-->}}}<!-- close {{{name|...}}}
______-->]]<!-- close link
-->|<!--

if {{{doc|}}} is null


______-->{{#ifexist:<!--
_______________-->{{#invoke: String<!-- invoke Module:String
________________-->| replace<!--
________________-->| source= {{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | <!--nothing--> }} }}}<!--
________________-->| pattern= .js<!-- Gets rid of .js extension.
________________-->| replace=<!--
________________-->}}<!--
______-->|<!-- if this page title exists
______________-->[[<!-- open link
______________-->{{#invoke: String<!--
______________-->|replace<!--
______________-->|source= {{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | <!--nothing--> }} }}}<!--
______________-->|pattern=.js|replace=<!--
______________-->}}<!-- Gets rid of .js extension.
______________-->|<!-- link name
______________-->{{{name| {{{name| {{SUBPAGENAME:<!--
___________________-->{{#invoke: String<!--
___________________-->| replace<!--
___________________-->| source= {{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | <!--nothing--> }} }}}<!--
___________________-->| pattern= .js<!--
___________________-->| replace=<!--
___________________-->}}<!-- Gets rid of .js extension.
___________________-->}} }}}<!--
______________-->}}}<!-- end link name
______________-->]]<!-- close link
______-->|<!-- else do this
______________-->{{{name| {{{name| {{SUBPAGENAME: {{#invoke: String|replace|source= {{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | <!--nothing-->}} }}}|pattern= .js |replace= }} }} }}} }}}<!--
_____-->}}<!--

end (if {{{doc|}}} is null)


-->}}<!-- end if





-->{{#if: {{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | <!--nothing--> }} }}}<!-- if this string isn't null
-->|{{#ifeq: {{{noautoinstall}}} | yes | <!--nothing--> |<!-- if {{{noautoinstall}}} is not equal to yes
_____-->{{#tag:ref|Copy the following code, '''<span title="Click here to edit your common.js page" class="plainlinks"><!--
_____-->[{{fullurl:Special:MyPage/common.js|action=edit}} click here]</span>''', then paste:<br /><!--
__________--><code>{{subst:iusc|1={{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js| <!--nothing--> }}}}}{{#ifeq:{{{backlink|}}}|<!--nothing-->|<!-- do nothing -->|{{!}}2{{=}}{{{backlink}}}<!-- else do this --> }}}} </code><!--
_____-->}} |<!--nothing-->}}<!-- close ifeq
-->}}<!-- close if






-->{{#if: {{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | <!--nothing--> }} }}} | <!-- if this string exists--
_____ --><small>([[{{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | <!--nothing--> }} }}}|source]])</small> <!--
____ -->|<!-- else do nothing
-->}}<!--




-->{{#ifeq: {{{noautoinstall}}} | yes |<!-- if {{{noautoinstall}}} = yes do nothing -->|<!-- else
_____ --><span <!-- open span tag
_____ -->id="{{{code| {{#ifexist: {{{doc|}}}.js | {{{doc|}}}.js | }} }}}"<!-- id value
_____ -->class="scriptInstallerLink"<!--supports automated installers, do not remove
_____ -->><!-- close span tag
--></span><!--
-->}}<!-- end of ifeq




https://en.wikipedia.org/wiki/Help:Magic_words

{{#ifexist:pagetitle |result1 |result2}} Outputs result1 if the page [[pagetitle]] exists, otherwise outputs result2. Note that underscores are needed for spaces in namespaces.


{{#if:string |result1 |result2}} Outputs result2 if string is empty, otherwise outputs result1.

{{#ifeq:string1|string2 |result1 |result2}} Outputs result1 if string1 and string2 are equal (alphabetically or numerically), otherwise outputs result2.

{{#tag:tag|content |p1=v1 |p2=v2}} An equivalent to the HTML <tag>...</tag> that is useful when e.g. nesting references.

https://en.wikipedia.org/wiki/Template:InstallUserScript

In order to install a user script for your Wikipedia account, add the following line to Special:MyPage/Common.js or Special:MyPage/Skin.js:

{{subst:iusc| script_path }}

Replace script_path with the full .js page name of the user script to be installed.
The template must but substituted (subst:), or else it won't work.
Bypass your cache after saving the page.


https://en.wikipedia.org/wiki/Template:= This template allows "=" to be used in template parameters.

https://en.wikipedia.org/wiki/Template:! outputs a pipe symbol.

https://en.wikipedia.org/wiki/Module:String

https://meta.wikimedia.org/wiki/Help:Page_name "{{SUBPAGENAME:a/b/c}}" → "c"









--></includeonly><noinclude>{{doc}}</noinclude>