Skip to content

Instantly share code, notes, and snippets.

@jonleung
Forked from vnorby/gist:4116565
Last active September 19, 2022 20:17
Show Gist options
  • Save jonleung/8345e59add5180cd5b4533aa977fc629 to your computer and use it in GitHub Desktop.
Save jonleung/8345e59add5180cd5b4533aa977fc629 to your computer and use it in GitHub Desktop.
Bookmarklet to embed Paul Graham's essay footnotes inline
javascript:(function(e, t, n, r, i, s, o, u) {
if (!(i = e.jQuery) || n > i.fn.jquery || r(i)) {
s = t.createElement("script");
s.type = "text/javascript";
s.src = "http://ajax.googleapis.com/ajax/libs/jquery/" + n + "/jquery.min.js";
s.onload = s.onreadystatechange = function() {
if (!o && (!(u = this.readyState) || u == "loaded" || u == "complete")) {
r((i = e.jQuery).noConflict(1), o = 1);
i(s).remove()
}
};
t.documentElement.childNodes[0].appendChild(s)
}
})(window, document, "1.8.3", function(e, t) {
var n = e("font[color]").filter(function() {
if (parseInt(e(this).text(), 10) > 0) {
return true
}
return false
}).parent();
var r = e("body").html();
n.each(function() {
var t = e(this).attr("href").replace("#", "");
var n = parseInt(t.replace("f", ""), 10);
var i = new RegExp('<a name="' + t + '">([^]*?)[[]');
var s = r.match(i);
if (s && s[0]) {
var o = e(s[0].replace("<br>", "\n")).text().replace(n + "]", "");
o = o.replace("csell_env = 'mud';", "").replace("// Begin Y! Store Generated Code", "");
var u = e('<div class="note" style="background:#FFFFFF;border:3px solid #000;left:0px;top:15px;width:300px;position:absolute;padding:10px;color:#000;text-decoration:none;">' + o + "</div>");
e(this).parent().html("Begin Sidenote. " + o + " End Sidenote.")
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment