Skip to content

Instantly share code, notes, and snippets.

@hkuno9000
Last active May 11, 2021 08:39
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 hkuno9000/4665e682f27ce71728341317c3e73aad to your computer and use it in GitHub Desktop.
Save hkuno9000/4665e682f27ce71728341317c3e73aad to your computer and use it in GitHub Desktop.
GitBucket print ready Bookmarklet and User-defined CSS
/** GitBuckect 4.3x's User-defined CSS にて gitbucket-print-ready.js と同等の印刷結果を得る */
/* コードブロックの背景色とボーダ設定が上書きされているので、さらに上書きする. */
div.markdown-body pre.prettyprint {
border: 1px solid #888!important;
background-color: #f5f5f5;
}
@media print {
/* コードブロックのスクロールバーは印刷時には無意味なので、行折り返しに変更する */
div.markdown-body pre.prettyprint {
margin-left: 2em;
white-space: pre-wrap;
word-wrap: break-word;
}
/* 編集操作関連の要素はすべて印刷対象から外す. */
form, *.octicon, a.btn, div.wiki-sidebar-dotted, div.discussion-item {
display: none;
}
/* Label,Priority,Milestone,Assignの設定と記録も印刷対象から外す. 印刷したい場合はコメントアウトする. */
div.col-md-3, div.discussion-item {
display: none;
}
}
javascript:
var e=document.getElementsByClassName("col-md-9")[0]||document.getElementsByClassName("wiki-main")[0];
var h=document.getElementsByClassName("show-title")[1]||document.getElementsByClassName("body-title")[0];
document.body.innerHTML="<h1>"+h.innerHTML+"</h1>"+e.innerHTML;
for(var p of document.getElementsByClassName("prettyprint"))
{p.style="margin-left:2em;white-space:pre-wrap;font-size:small;border:solid";}
alert('Ready to print out');
@hkuno9000
Copy link
Author

hkuno9000 commented Feb 22, 2018

How To Install the bookmarklet

  1. create a new bookmark on your browser.
  2. open dialog of the bookmark.
  3. copy above 7lines code; that are "javascript: ... alert()". then paste them to the URL field on dialog.
  4. open GitBucket Wiki or Issue page, and click the bookmark.
  5. You got a "Ready to print out page"!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment