Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.