I’m unsure if I’m allowed, and before I go doing anything I’d want to ask how and if I can.
I’d like to add my script as a dev script:
$(document).ready(function () {
$('.mw-parser-output h2, .mw-parser-output h3').not('aside h2, aside h3').each(function () {
var header = $(this);
var content = [];
var next = header.next();
var stopAt = header.is('h2') ? 'h2' : 'h2, h3';
while (next.length && !next.is(stopAt)) {
content.push(next);
next = next.next();
}
if (content.length === 0) return;
var toggle = $('<span>')
.text('▼')
.css({
cursor: 'pointer',
fontSize: '12px',
color: 'gray',
float: 'right',
marginRight: '8px',
userSelect: 'none'
})
.on('click', function () {
var collapsed = $(this).data('collapsed');
$.each(content, function () { $(this).toggle(collapsed); });
$(this).text(collapsed ? '▼' : '►');
$(this).data('collapsed', !collapsed);
})
.data('collapsed', false);
header.prepend(toggle);
});
});
Suggested name?: CollapsibleHeaders
What does it do?: On the far right of headers, adds a small arrow to collapse/expand them, this includes all contents in them, such as sub headings.
Uh… so yeah!