Last active
February 14, 2024 11:14
-
-
Save scarf005/0bf5f4512fd69c85e150523ab18f830a to your computer and use it in GitHub Desktop.
remove stackoverflow sidebars and other junks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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' | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, @scarf005.