User:Anakin101/sectionlinks.js

/* Script to add [prev] and [next] section links beside the [edit] link on section headings */

$(function {	var spans = document.getElementsByTagName('span');	var headlines = Array('top');	for (var i = 0; i < spans.length; i++) {		if (spans[i].className === 'mw-headline') {			headlines.push(spans[i].id);		}	}	for (var i = 0, j = 0; i < spans.length; i++) {		if (spans[i].className !== 'mw-headline') continue;		var newlinks = document.createElement('span');		var prev, next;		prev = 'prev';		if (j < headlines.length - 1) {			next = 'next';		} else {			next = 'next';		}		newlinks.innerHTML = ' [' + prev + '] [' + next + '] ';		newlinks.className = 'editsection';			spans[i].parentNode.insertBefore(newlinks, spans[i]);			i += 2;	} });