Skip to content

Instantly share code, notes, and snippets.

@RuslanUC
Created February 27, 2026 18:09
Show Gist options
  • Select an option

  • Save RuslanUC/0e445bae931cea829af09ad4258697a0 to your computer and use it in GitHub Desktop.

Select an option

Save RuslanUC/0e445bae931cea829af09ad4258697a0 to your computer and use it in GitHub Desktop.
Tempermonkey userscript to remove useless ui elements on stackexchange websites
// ==UserScript==
// @name Better StackExchange ui
// @namespace http://tampermonkey.net/
// @version 2026-02-22
// @description Remove useless ui elements on stackexchange websites
// @author RuslanUC
// @match https://stackoverflow.com/questions/*
// @match https://*.stackoverflow.com/questions/*
// @match https://askubuntu.com/questions/*
// @match https://stackexchange.com/questions/*
// @match https://*.stackexchange.com/questions/*
// @match https://serverfault.com/questions/*
// @match https://superuser.com/questions/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=stackoverflow.com
// @grant none
// @run-at document-idle
// ==/UserScript==
(function() {
'use strict';
document.getElementById("left-sidebar")?.remove();
document.getElementById("sidebar")?.remove();
document.getElementById("post-form")?.remove();
document.querySelectorAll(".js-post-menu").forEach(el => el.remove());
document.querySelectorAll(".js-post-comments-component").forEach(el => el.remove());
document.querySelectorAll(".js-you-can-comment-banner-anon").forEach(el => el.remove());
document.querySelectorAll(".post-layout--right > div > div > div.d-flex.g8.my8").forEach(el => el.remove());
document.querySelectorAll(".post-layout--right > div > div > div.mb12").forEach(el => el.remove());
document.querySelectorAll(".js-bottom-notice").forEach(el => el.remove());
document.querySelectorAll("#question-header > div.ml12").forEach(el => el.remove());
const content = document.getElementById("content");
content.style.maxWidth = "100%";
content.style.width = "100%";
content.style.border = "none";
const mainbar = document.getElementById("mainbar");
mainbar.style.maxWidth = "100%";
mainbar.style.width = "100%";
document.querySelectorAll(".container").forEach(el => {
el.style.maxWidth = "100%";
el.style.width = "100%";
});
document.querySelectorAll("header > div.s-topbar--container").forEach(el => {
el.style.maxWidth = "100%";
el.style.width = "100%";
});
document.querySelectorAll("p > a > img").forEach(el => {
if(!el.src.contains("sstatic.net") || !el.parentNode.href.contains("sstatic.net")) {
return;
}
const elements = el.parentNode.parentNode.childNodes;
const index = Array.prototype.indexOf.call(elements, el.parentNode);
if(index > 0 && elements[index - 1].nodeType === 3) {
const beforeBreak = document.createElement("br");
el.parentNode.parentNode.insertBefore(beforeBreak, el.parentNode);
}
if(index < (elements.length - 1) && elements[index + 1].nodeType === 3) {
const afterBreak = document.createElement("br");
el.parentNode.parentNode.insertBefore(afterBreak, elements[index + 1]);
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment