Wikipedia:User scripts/Guide: Difference between revisions
Content deleted Content added
No edit summary |
Z. Patterson (talk | contribs) Tag: Reverted |
||
Line 73:
</syntaxhighlight>
(We separate the two "{" brackets in the front of the wikify template so it
Finally, we want to submit the form for the user. Luckily, JavaScript has a built-in function just for this named <code>submit()</code>. To submit our editing form, use <code>document.editform.submit()</code>. Your code should now look something like this:
Line 84:
</syntaxhighlight>
<syntaxhighlight lang="javascript" copy style="min-width:fit-content; max-width: 40%">
Line 151:
On Windows, you could also use for example [https://www.ritlabs.com/en/products/tinyweb/download.php TinyWeb], less than 100 kbyte on disk and not requiring installation. Save and unzip <kbd>tinyweb.zip</kbd> for example into <kbd>c:\Program Files\Tinyweb</kbd>, create a shortcut to <kbd>tiny.exe</kbd>, and add an argument in shortcut properties — path to your folder with <kbd>wikipediatest.js</kbd> and any file <kbd>index.html</kbd> (required). Start TinyWeb with this shortcut; unload it with Task Manager.
Note that this method
=== Browser-specific ===
Line 187:
These are typically built into browsers, in their DevTools window. Debuggers allow you to step debug (go through your JavaScript code line-by-line, hover over variables to see their values, etc.)
* [[Firefox]]
* [[Google Chrome|Chrome]] and [[Microsoft Edge|Edge]]
* [[Safari (web browser)|Safari]]
* [[Opera browser|Opera]]
== Basic techniques ==
Line 309:
* Top
** <span style="color:green;">p-personal</span>
** <span style="color:red;">p-namespaces</span>
**<span style="color:red;">p-views</span>
**<span style="color:green;">p-cactions</span>
** <span style="color:red;">p-search</span>
* Left
** <span style="color:red;">p-logo</span>
** <span style="color:green;">p-navigation</span>
** <span style="color:green;">p-interaction</span>
** <span style="color:green;">p-tb</span>
** <span style="color:red;">p-coll-print_export</span>
**<span style="color:red;">p-wikibase-otherprojects</span>
** <span style="color:red;">p-lang</span>
==== Portlet structure ====
Line 501:
==== Get the wikitext of a page ====
===== Using module <code>mediawiki.api</code>=====
Note: make sure to add <code>mediawiki.api</code> to your dependencies
<syntaxhighlight lang="javascript" copy style="min-width:fit-content; max-width: 40%">
function doSomethingWithText( wikitext ) {
Line 575:
The code below shows how to edit a page, but it can easily be adapted to other actions by reading the [{{SERVER}}/w/api.php API documentation].
===== Using module <code>mediawiki.api</code>=====
Note: make sure to add <code>mediawiki.api</code> to your dependencies
<syntaxhighlight lang="javascript" copy style="min-width:fit-content; max-width: 40%">
// Edit page via the mw.Api module.
|