-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
SaveAllEntries.js
31 lines (29 loc) · 1.09 KB
/
SaveAllEntries.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("entry")];
let result = [];
target.forEach((element) => {
let regExpLiteral = /Published:.(.*)/i;
result.push({
title: element.querySelector(".EntryTitle").innerText,
url: element.querySelector("a:not(.entry__source)").href,
summary: element.querySelector(".EntrySummary").innerText,
time: regExpLiteral.exec(element.querySelector("span.ago").title)[1],
sourceTitle: element.querySelector(".entry__source")?.innerText,
sourceUrl: element.querySelector(".entry__source")?.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(blob);
};
saveToFile(convertEntries());