Skip to content

Instantly share code, notes, and snippets.

@brgr
Created December 19, 2023 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brgr/8f244b3d94069cd937d4e00f21fc7adb to your computer and use it in GitHub Desktop.
Save brgr/8f244b3d94069cd937d4e00f21fc7adb to your computer and use it in GitHub Desktop.
On a Wikipedia article, move navboxes to the top of the page. Navboxes are the informative boxes with many further links on the topic, normally (but not always) at the bottom of a Wikipedia article.
// ==UserScript==
// @name Move All Navboxes to Top
// @namespace http://your.namespace.com
// @version 1.0
// @description On a Wikipedia article, move navboxes, if they exist, to the top of the page
// @author Your Name
// @match *://en.wikipedia.org/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var navboxes = document.querySelectorAll('.navbox');
// This is where the wikipedia article starts
var mwContent = document.querySelector('.mw-content-ltr');
if (navboxes.length > 0 && mwContent) {
var fragment = document.createDocumentFragment();
navboxes.forEach(function(navbox) {
fragment.appendChild(navbox);
});
mwContent.insertBefore(fragment, mwContent.firstChild);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment