User:SitX/vector-2022.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
mw.loader.using('mediawiki.util').then(function() {
function expandSidebar() {
document.body.classList.add('is-menu-expanded');
localStorage.setItem("vector-sidebar-visible", "true");
}
function forceSidebarForAnonymous() {
if (mw.config.get("wgUserName") === null) { // User is anonymous
expandSidebar();
}
}
if (document.readyState === "complete") {
expandSidebar();
forceSidebarForAnonymous();
} else {
window.addEventListener("load", function() {
expandSidebar();
forceSidebarForAnonymous();
});
}
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.attributeName === "class") {
if (!document.body.classList.contains('is-menu-expanded')) {
expandSidebar();
forceSidebarForAnonymous();
}
}
});
});
observer.observe(document.body, { attributes: true });
});