Skip to content

Instantly share code, notes, and snippets.

@scarf005
Last active February 14, 2024 11:14
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 scarf005/0bf5f4512fd69c85e150523ab18f830a to your computer and use it in GitHub Desktop.
Save scarf005/0bf5f4512fd69c85e150523ab18f830a to your computer and use it in GitHub Desktop.
remove stackoverflow sidebars and other junks
// ==UserScript==
// @name Sanitize Stackoverflow
// @namespace https://gist.github.com/scarf005/
// @version 0.2.1
// @description excesive information is crime
// @author scarf005
// @match https://stackoverflow.com/*
// @match https://*.stackexchange.com/*
// @match https://askubuntu.com/*
// @match https://superuser.com/*
// @match https://serverfault.com/*
// @grant none
// ==/UserScript==
(() => {
'use strict'
// elements to remove
const clsToRemove = [
'.top-bar',
'.left-sidebar', //.ps-relative.js-pinned-left-sidebar.left-sidebar left sidebar
'.show-votes', // right sidebar
'.js-dismissable-hero', // asking you to sign up
'.js-announcement-banner', // something something annoucements
'.site-footer--container', // footer
'.bottom-notice', // prompt that asks you to search other questions tagged or post your own
'.list-reset', // about, products, for teams on nav bar
'.user-logged-out.h100.list-reset.ai-center.d-flex.-secondary.ml-auto.overflow-x-auto', // login prompt at search bar
'.post-form.js-add-answer-component', // post your own answer
'.js-consent-banner', // stackexchange policy banner
'.s-btn', // buttons that you weren't going to press anyway
].flatMap(cls => Array.from(document.querySelectorAll(cls)))
const tagsToRemove = ['footer']
.flatMap(t => Array.from(document.getElementsByTagName(t)))
const totalToRemove = [...clsToRemove, ...tagsToRemove]
totalToRemove
.forEach(e => e.remove())
// fit mainbar to empty spaces
document.getElementById('mainbar').style.width = 'auto'
})()
@sergeevabc
Copy link

Thank you, @scarf005.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment