Skip to content

Instantly share code, notes, and snippets.

@kpym
Last active March 28, 2019 19:38
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 kpym/0e595241caeaccefdecdb09d4186c376 to your computer and use it in GitHub Desktop.
Save kpym/0e595241caeaccefdecdb09d4186c376 to your computer and use it in GitHub Desktop.
Greasemonkey : Add print style to stackexchange.com (SX).
// ==UserScript==
// @name Add print style to SX
// @namespace https://gist.github.com/kpym/0e595241caeaccefdecdb09d4186c376
// @version 0.1
// @description This script inject @media print CSS to SX websites
// @author kpym
// @match http*://*.stackexchange.com/*
// @grant GM_addStyle
// ==/UserScript==
/* jshint -W097 */
'use strict';
// ------------------------------------------
// CSS part injected in the page
GM_addStyle(" \
@media print { \
* { \
visibility: hidden; \
} \
#content * { \
visibility: visible; \
} \
header, #left-sidebar, #sidebar, form, .bottom-notice, .comments-link, .aside-cta { \
display: none; \
} \
#mainbar { \
width: 100%; \
} \
div.post-text { \
page-break-inside: avoid; \
} \
} \
");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment