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