Skip to content

Instantly share code, notes, and snippets.

@andrewgilmartin
Last active August 29, 2015 14:08
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save andrewgilmartin/26fd5b2ce02a3219c96c to your computer and use it in GitHub Desktop.
Bookmarklet to cleanup Kindle Your Highlights page
javascript:(function(){
var O = $('<div class="books"/>');
var S;
var xs = $("#allHighlightedBooks").children();
for ( var i = 0; i < xs.length; i++ ) {
var x = $(xs[i]);
var c = x.attr("class");
if ( c.indexOf("bookMain") != -1 ) {
t = $('.title',x).text();
a = $('.author',x).text();
l = $('a',x).attr("href");
b = $('<div class="book"/>').appendTo(O);
$('<div class="title"/>').text(t).appendTo(b);
$('<div class="author"/>').text(a).appendTo(b);
$('<div class="link"><a href="'+l+'">'+l+'</a></div>').appendTo(b);
S = $('<div class="selections"/>').appendTo(b);
}
else if ( c.indexOf("highlightRow") != -1 ) {
h = $('.highlight',x).text();
n = $('.noteContent',x).text();
l = $('.linkOut',x).attr("href");
x = $('<div class="selection"/>').appendTo(S);
$('<div class="selection"/>').text(h).appendTo(x);
$('<div class="note"/>').text(n).appendTo(x);
$('<div class="link"><a href="'+l+'">'+l+'</a></div>').appendTo(x);
}
}
$(window.document.head).html(
'<style>' +
'div { margin-bottom: 1ex; }' + "\n" +
'.title { font-weight: bold; }' +
'</style>'
);
$(window.document.body).html(O[0].outerHTML);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment