Skip to content

Instantly share code, notes, and snippets.

@vyznev
Last active August 26, 2021 17:09
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 vyznev/607e86f3890d920f67d7cbd6c5f78e7b to your computer and use it in GitHub Desktop.
Save vyznev/607e86f3890d920f67d7cbd6c5f78e7b to your computer and use it in GitHub Desktop.
Enable sticky vote buttons on Stack Exchange sites
// ==UserScript==
// @name SE Sticky Vote Buttons
// @namespace https://github.com/vyznev/
// @description Enable sticky vote buttons on Stack Exchange sites
// @author Ilmari Karonen
// @version 0.6.0
// @copyright 2018-2021, Ilmari Karonen
// @downloadURL https://gist.github.com/vyznev/607e86f3890d920f67d7cbd6c5f78e7b/raw/se-sticky-vote-buttons.user.js
// @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 = `
.votecell .js-voting-container { position: -webkit-sticky; position: sticky; top: calc(var(--top-bar-allocated-space) + 10px); z-index: 1 }
body:not(.no-grid-post-layout) .post-layout--left.votecell { grid-row: 1 / 3 }
.votecell .js-voting-container .message { width: 480px }
body .post-layout { overflow: visible }
`;
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