Last active
April 4, 2022 07:57
-
-
Save vyznev/7c9a7ddc5c057d4c895864e460b4a88d to your computer and use it in GitHub Desktop.
Disable the sticky top bar on Stack Exchange sites
This file contains 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 SE No Sticky Top Bar | |
// @namespace https://github.com/vyznev/ | |
// @description Disables the sticky top bar on Stack Exchange sites | |
// @author Ilmari Karonen | |
// @version 0.3.0 | |
// @copyright 2021-2022, Ilmari Karonen | |
// @downloadURL https://gist.github.com/vyznev/7c9a7ddc5c057d4c895864e460b4a88d/raw/se_no_sticky_topbar.user.js | |
// @homepageURL https://meta.stackexchange.com/a/368984 | |
// @match *://*.stackexchange.com/* | |
// @match *://*.stackoverflow.com/* | |
// @match *://*.superuser.com/* | |
// @match *://*.serverfault.com/* | |
// @match *://*.stackapps.com/* | |
// @match *://*.mathoverflow.net/* | |
// @match *://*.askubuntu.com/* | |
// @exclude *://chat.*/* | |
// @exclude *://blog.*/* | |
// @grant none | |
// @run-at document-start | |
// @noframes | |
// ==/UserScript== | |
var css = ` | |
html:not(.specificity-hack) { --top-bar-allocated-space: 0px; } | |
body:not(.specificity-hack) { padding-top: 0px; } | |
.s-topbar.ps-fixed:not(.specificity-hack) { position: static !important; } | |
`; | |
var style = document.createElement('style'); | |
style.textContent = css; | |
var parent = (document.head || document.documentElement); | |
if (parent) parent.appendChild(style); | |
else { | |
// work-around for https://github.com/greasemonkey/greasemonkey/issues/2996 | |
var obs = new MutationObserver(function () { | |
var parent = (document.head || document.documentElement); | |
if (parent) { obs.disconnect(); parent.appendChild(style); } | |
}); | |
obs.observe(document, {childList: true}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment