Jump to content

英文维基 | 中文维基 | 日文维基 | 草榴社区

User:The Evil IP address/hdedit

From Wikipedia, the free encyclopedia

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

[edit]

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

[edit]

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

[edit]
  • 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

[edit]

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.