forked from Barabazs/Feedly-Export-Save4Later
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SaveSavedEntries.js
31 lines (29 loc) · 1.16 KB
/
SaveSavedEntries.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
let convertEntries = () => {
"use strict";
let target = [...document.getElementsByClassName("quicklisted")];
let result = [];
target.forEach((element) => {
let regExpLiteral = /Published:.(.*)/i;
result.push({
title: element.getAttribute("data-title"),
url: element.getAttribute("data-alternate-link"),
summary: element.querySelectorAll(".summary")[0].innerHTML,
time: regExpLiteral.exec(element.querySelectorAll("span.ago")[0].title)[1],
sourceTitle: element.querySelectorAll(".source")[0].innerHTML,
sourceUrl: element.querySelectorAll(".source")[0].href,
});
});
return result;
};
let saveToFile = (input) => {
"use strict";
let json = JSON.stringify(input, undefined, 2);
let blob = new Blob([json], { type: "text/plain;charset=utf-8" });
let downloadLink = document.createElement("a");
downloadLink.href = URL.createObjectURL(blob);
let fileName = "FeedlySavedForLater" + Date.now().toString() + ".json";
downloadLink.download = fileName;
downloadLink.click();
URL.revokeObjectURL(a.href);
};
saveToFile(convertEntries());