User:LeDesespere/common.js

/* function toggleTOCSidebar (event) { return sidebarTOCContainer.toggleAttribute("hidden"); }

var toc = document.getElementById("toc")

var sidebarTOCContainer = document.createElement("div"); sidebarTOCContainer.id = "sidebar-toc-container"; sidebarTOCContainer.insertAdjacentElement("afterbegin", toc.cloneNode);

var buttonContainer = document.createElement("div"); buttonContainer.id = "button-container";

var toggleTOCButton = document.createElement("button"); toggleTOCButton.innerHTML = "Toggle"; toggleTOCButton.classList.add("toggle-sidebar-toc"); toggleTOCButton.addEventListener("click", toggleTOCSidebar); buttonContainer.insertAdjacentElement("afterbegin", toggleTOCButton)

var toggleTOCButtonClone = toggleTOCButton.cloneNode(true); toggleTOCButtonClone.addEventListener("click", toggleTOCSidebar);

var navigationElement = document.getElementById('mw-site-navigation'); navigationElement.insertAdjacentElement("afterbegin", sidebarTOCContainer); navigationElement.insertAdjacentElement("afterbegin", buttonContainer); toc.insertAdjacentElement("afterbegin", toggleTOCButtonClone);