var pageUrl = window.location.href; var username = $(".path__username > a").eq(0).text(); var channelId = $(".channel > span").eq(0).attr("id").slice(16); var channelName = $(".channel > span").eq(0).text(); // $.ajax({ // //type: 'GET', // url: 'https://api.are.na/v2/channels/' + channelId + '/contents', // data: { get_param: 'value' }, // dataType: 'json', // success: function (data) { // console.log(data.contents); // // $.each(data, function(index, element) { // // console.log(element.contents.title); // // }); // } // }); var blocks = []; var firstPage = $('
').addClass("page").append("

Are.na /
" + username + " /
" + channelName + "

\n"); $.getJSON(chrome.extension.getURL('contents.json'), function(data) { //console.log(data); var channelContents = data.contents; $.each(channelContents, function( index, block ) { var datetime = new Date(block.created_at).toLocaleDateString(); blocks[index] = "
\n" + "
\n" + "
\n" + ( block.title == null ? "

"+ block.generated_title + "

\n" : "

" + block.title + "

\n" ) + "

URLhttps://www.are.na/block/"+ block.id + "
\n" + "User " + block.user.full_name + "
\n" + "Date

\n" + "
\n" + ( block.content_html ? "
"+ block.content_html + "
\n" : "" ) + ( block.image ? "
\n\n" + ( block.description_html ? "
" + block.description_html + ( block.source ? "Source: "+ block.source.url + "\n" : "" ) + ( block.attachment ? "PDF: "+ block.attachment.url + "\n" : "" ) + "
\n" : "") + "
\n" : "" ) + "\n" + "
\n" + "
"; }); }); //console.log(blocks); $.get(chrome.extension.getURL('head.html'), function( head ) { $( "head" ).html( head ); }); $.get(chrome.extension.getURL('body.html'), function( pages ) { $( "body" ).html( pages ); $( "#pages" ).append(firstPage); $.each(blocks, function( index, block ) { $( "#pages" ).append(block); }); }); // Print //window.print();