User:The Evil IP address/hdedit
The Heading editor allows for simple one-click editing of section titles w/o having to open the edit form for either the whole page or the section. You can change the section title on the fly and then keep on reading the article.
Usage
Copy the following to your common.js:
{{subst:iusc|User:The Evil IP address/hdedit.js}}
The script has been tested for the skins Vector (2022), Vector legacy (2010), MinervaNeue, MonoBook and Timeless up until June 2024.
To use it, make a left-mouse click on a section and within seconds an input box w/ the formatting of the section title will appear. Change it, press "Save" or press "Cancel" if you don't need to make any changes. The script supports the following formatting in section titles:
- Bold and italics
- Template coding, e.g. {{Done}} or similar
- Internal or external links only if there's some other content than the link and you click on that; this is intentionally to be compatible w/ common clicking behaviour, furthermore there are few of this sort
- Unclickable images; clickable images again don't work for the reason given above
- It works on any page in any namespace; it might not be necessary anywhere, but currently I don't see a "no-go" for any namespace
- The script leaves spacing exactly as is, to avoid any holy wars about this subject
- Edits are marked as minor
- You can't use this script while editing; theoretically doable, but this would be another approach that isn't within the scope of this script
- Section heading using HTML formatting
<h1>
,<h2>
, ..., cannot be edited using this script, as they cannot be accessed like the other section headings via the API - Section headings transcluded from a template cannot be edited using this script, as this may affect more than the current page, and thus should be edited manually. Also, it would be considerably more difficult to do so automatically.
- The script is very probably not loaded on protected pages.
- The script is disabled on the wiki's Main Page for security. For the English-language Wikipedia it probably wouldn't be relevant anyway. The Main Page uses HTML formatting which this script does not support. However, this precaution is also included for other wikis using or copying this script.
- The script is disabled on fully-protected pages per this suggestion. Such pages should be edited manually and not by scripts.
Preferences
It's possible to customize what triggers the opening of the edit form. Possibilities are a single click, a double click, a click with the right mouse button, and any combination of these.
By default, the editform opens on a single click. If you want to change this, use the following code instead in your common.js.
Note that window.hdedit_prefs
has to come before the code {{subst:iusc|User:The Evil IP address/hdedit.js}}
, or the preference won't be loaded in time!
- Double-click
window.hdedit_prefs = {
'eventToActivate': 'dblclick' // activate hdedit on double click
};
{{subst:iusc|User:The Evil IP address/hdedit.js}}
- Right mouse click
window.hdedit_prefs = {
'eventToActivate': 'contextmenu' // activate hdedit on right mouse click
};
{{subst:iusc|User:The Evil IP address/hdedit.js}}
- a combination of them
window.hdedit_prefs = {
'eventToActivate': 'contextmenu dblclick' // activate hdedit on double click and right mouse click
};
{{subst:iusc|User:The Evil IP address/hdedit.js}}
To do
- Save the values through a page reload or alternatively, don't reload at all, but catch the parsed heading from the API, so one can edit multiple section titles once
- ...
Bugs/Feedback
This script is a work in progress. If you have encountered any bug while using it, or you have any suggestions on how to make it better, please let me know on my talk page. Thank you.
- this edit by Ser Amantio di Nicolao went through full protection. Not that there's any problem with the edit, but scripts should not make content changes to fully-protected articles when run with admin accounts I think, changes should only be made in response to {{editprotected}}. Guy (help! - typo?) 20:30, 8 October 2020 (UTC)
- Hello Guy, I've added a change that should disable the script on fully-protected pages. However I cannot test the change myself as I'm not an administrator. Would you or another administrator shortly test that the script is behaving as expected. This could be done on a (temporarily) fully-protected page in your userspace, e.g. your sandbox. The expected behaviour is that clicking on a section heading does not load the usual edit form of this script. No error message is shown, the functionality of the script is simply not loaded on fully-protected pages. The Evil IP address (talk) 08:38, 11 July 2021 (UTC)