Reputation: 255
I found a script that's used to extract saved articles from Feedly (by running it inside Chrome's Inspect Element console), but I'd like to tweak it a bit for my needs. I'm not a developer or anything like that so I'd appreciate it if someone could help!
Here's part of the script:
json = ""
function copyToClipboard() {
// Loop through the DOM, grabbing the information from each bookmark
map = jQuery("#section0_column0 div.u0Entry.quicklisted").map(function(i, el) {
var $el = jQuery(el);
var regex = /published:(.*)\ --/i;
return {
title: $el.data("title"),
url: $el.data("alternate-link"),
time: regex.exec($el.find("div.lastModified span").attr("title"))[1]
};
}).get(); // Convert jQuery object into an array
// Convert to a nicely indented JSON string
json = JSON.stringify(map, undefined, 2)
Here's an example of what it returns:
[
{
"title": "Blog post headline",
"url": "http://urlofblogpost.com/article",
"time": "Tue, 10 Dec 2014 21:00:00 GMT"
},
{
"title": "Blog post2 headline",
"url": "http://urlofblogpost.com/article2",
"time": "Tue, 10 Dec 2014 21:00:00 GMT"
},
]
Here's what I'd like it to return:
<a href="http://urlofblogpost.com/article">Blog post headline</a>
<a href="http://urlofblogpost.com/article2">Blog post2 headline</a>
The most I could do on my own was delete the "time" part from the script, remove the brackets, and isolate the titles and URLs (using a text editor):
Blog post headline
http://urlofblogpost.com/article
Is there any way to change the script to get it in links?
Upvotes: 0
Views: 85
Reputation: 1036
Just Iterate through the json:
Javascript:
function copyToClipboard() {
// Loop through the DOM, grabbing the information from each bookmark
map = jQuery("#section0_column0 div.u0Entry.quicklisted").map(function(i, el) {
var $el = jQuery(el);
var regex = /published:(.*)\ --/i;
return {
title: $el.data("title"),
url: $el.data("alternate-link"),
time: regex.exec($el.find("div.lastModified span").attr("title"))[1]
};
}).get(); // Convert jQuery object into an array
var theLink = '';
$.each(yourJson, function(k,v){
theLink += "<a href=" + v.url + " >" + v.title + " </a>, \n";
});
window.prompt('my link', theLink);
I create js fiddle for you play: http://jsfiddle.net/reptildarat/GG5BP/4/
Upvotes: 1