Wikipedia:User scripts/Guide: Difference between revisions

Content deleted Content added
m Lint error
 
(3 intermediate revisions by 3 users not shown)
Line 180:
** [[PhpStorm]] (not free, cross-platform, a free license for MediaWiki Developers is also available<ref>https://lists.wikimedia.org/pipermail/mediawiki-l/2010-June/034396.html</ref>)
* Linux
** [[Neovim]]/[[Emacs]]
** [[gedit]] (may come with Linux)
** [[Kate (text editor)|Kate]], (mayfor comeKDE-based with Linux)desktops
** [[GNOME Text Editor]], for [[GNOME]]
 
=== JavaScript Debuggers ===
Line 414 ⟶ 416:
</syntaxhighlight>
 
You can manipulate it using the [https://doc.wikimedia.org/mediawiki-core/master/js/jQueryPlugins.html#module-jquery.textSelection.html jquery.textSelection] ResourceLoader module.
<syntaxhighlight lang="javascript" copy style="min-width:fit-content; max-width: 40%">
var $textbox = $( '#wpTextbox1' );
Line 440 ⟶ 442:
==== Edittools ====
There is another edit panel under textarea. Usually it is generated from [[MediaWiki:Edittools]] by [[mw:Extension:CharInsert|Extension:CharInsert]] and consists of a lot of JavaScript links. In the English Wikipedia, this approach was replaced by [[MediaWiki:Gadget-charinsert.js]] and [[MediaWiki:Gadget-charinsert-core.js]].
 
==== Automatic and semi-automatic editing ====
You can automate the editing of a page using the following code template:
 
<syntaxhighlight lang="javascript" copy style="min-width:fit-content; max-width:40%;">
mw.loader.using("mediawiki.user", () => {
$.post( mw.config.get('wgScriptPath') + '/api.php', {
action: 'edit',
title: "[Page title]",
text: "[Text]",
summary: "[Edit summary]",
token: mw.user.tokens.get('csrfToken'), // This is the user token required to authorize the edit.
format: 'json'
}).then(function(r){
if (r.error) {
mw.notify(r.error.info, {type: 'error', title: 'Error while trying to edit'}); // Sends an error message if unable to edit the page.
}
});
});
</syntaxhighlight>
 
=== Doing something after another user script ===