Skip to content

Instantly share code, notes, and snippets.

@mathcass
Created May 23, 2018 03:44
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 mathcass/44bee1f39516d14608042fa500b7d065 to your computer and use it in GitHub Desktop.
Save mathcass/44bee1f39516d14608042fa500b7d065 to your computer and use it in GitHub Desktop.
Bookmarklet to turn a website into Markdown
// Thanks to https://gist.githubusercontent.com/ImJasonH/c00cdd7aece6945fb8ea/raw/220c97f9e756f5f61eb18630fd7943e3a88e2940/
// Copy the start of javascript to the end and paste it into your bookmark.
// Make sure not to have comments
javascript: (function () {
var list= document.getElementsByTagName('link');
for (var i = 0; i < list.length; i++) {
list[i].parentNode.removeChild(list[i]);
}
var styleSheet = `
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
h1::before { content: "# "; }
h2::before { content: "## "; }
h3::before { content: "### "; }
h4::before { content: "#### "; }
h5::before { content: "##### "; }
h6::before { content: "###### "; }
strike::after, strike::before { content: "~~"; }
i::before, i::after { content: "*"; }
b::before, b::after { content: "**"; }
ol, ul { list-style: none; padding-left: 0; }
ul li::before { content: "* "; }
ol li::before { content: "1. "; }
code::before, code::after { content: "\`"; }
pre::before { content: "\`\`\`" attr(lang) "\\A"; }
pre::after { content:"\\A\`\`\` \\A"; }
a::before { content: "["; }
a::after { content: "](" attr(href) ")"; }
tr::before { content: "| "; }
td::after { content: " | "; }
thead td::after { content: " | \\A-----| "; white-space: pre; }
`;
var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = styleSheet;
document.getElementsByTagName('head')[0].appendChild(style);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment