Skip to content

Commit aa35fb2

Browse files
committed
export saved fb + fix desc docDownloader
1 parent da936b9 commit aa35fb2

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

scripts/docDownloader.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ export default {
77
vi: "DocDownloader - Tải document",
88
},
99
description: {
10-
en: "Download document on Scribd ,Issuu ,Slideshare ,Academia",
11-
vi: "Tải document từ Scribd ,Issuu ,Slideshare ,Academia",
10+
en: "Download document on Scribd, Issuu, Slideshare, Academia",
11+
vi: "Tải document từ Scribd, Issuu, Slideshare, Academia",
1212
},
1313
onClickExtension: async () => {
1414
let tab = await getCurrentTab();

scripts/fb_exportSaved.js

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
import { runScriptInCurrentTab, showLoading } from "./helpers/utils.js";
1+
import {
2+
downloadData,
3+
runScriptInCurrentTab,
4+
showLoading,
5+
} from "./helpers/utils.js";
26

37
export default {
48
icon: '<i class="fa-solid fa-file-export fa-lg"></i>',
59
name: {
6-
en: "Export saved items from facebook",
10+
en: "Export saved facebook items",
711
vi: "Xuất mục đã lưu trên facebook",
812
},
913
description: {
10-
en: "Export all your saved items on facebook",
11-
vi: "Xuất ra file các mục đã lưu của bạn trên facebook",
14+
en: "Export all your saved items on facebook to json file",
15+
vi: "Xuất ra file các mục đã lưu của bạn trên facebook ra file json",
1216
},
1317

1418
onClickExtension: async function () {
15-
const encodeHTML = (e) =>
16-
e?.replace(/([\u00A0-\u9999<>&])(.|$)/g, function (e, a, t) {
17-
return "&" !== a || "#" !== t
18-
? (/[\u00A0-\u9999<>&]/.test(t) && (t = "&#" + t.charCodeAt(0) + ";"),
19-
"&#" + a.charCodeAt(0) + ";" + t)
20-
: e;
21-
});
22-
2319
const c = (e) => {
2420
try {
2521
return e();
@@ -50,27 +46,30 @@ export default {
5046
let data = [];
5147
let page = 1;
5248
while (true) {
53-
setLoadingText("Đang tải trang " + page + "...");
49+
setLoadingText(
50+
`Đang tải trang ${page}...<br/>Tải được ${data.length} mục`
51+
);
5452
let json = await getSaved(uid, fb_dtsg, cursor);
5553
console.log(json);
5654
json.data.viewer.saver_info.all_saves.edges.forEach((e) => {
5755
data.push({
58-
title: encodeHTML(c(() => e.node.savable.savable_title.text)),
56+
title: c(() => e.node.savable.savable_title.text),
5957
type: c(() => e.node.savable.__typename),
6058
image: c(() => e.node.savable.savable_image.uri),
6159
url: c(() => e.node.savable.url),
6260
urlPost: c(() => e.node.container_savable.savable_permalink),
63-
sourceType: c(
64-
() => e.node.container_savable.savable_actors[0].__typename
65-
),
66-
sourceName: c(
67-
() => e.node.container_savable.savable_actors[0].name
68-
),
69-
sourceID: c(() => e.node.container_savable.savable_actors[0].id),
70-
sourceImage: c(
71-
() =>
72-
e.node.container_savable.savable_actors[0].profile_picture.uri
73-
),
61+
source: {
62+
type: c(
63+
() => e.node.container_savable.savable_actors[0].__typename
64+
),
65+
name: c(() => e.node.container_savable.savable_actors[0].name),
66+
id: c(() => e.node.container_savable.savable_actors[0].id),
67+
avatar: c(
68+
() =>
69+
e.node.container_savable.savable_actors[0].profile_picture.uri
70+
),
71+
},
72+
containingLists: c(() => e.node.containing_lists.nodes),
7473
});
7574
});
7675
let nextCursor = c(
@@ -92,7 +91,10 @@ export default {
9291
]);
9392
setLoadingText("Đang lấy dữ liệu...");
9493
let saved = await getAllSaved(uid, fb_dtsg);
95-
console.log(saved);
94+
95+
if (saved.length)
96+
downloadData(JSON.stringify(saved, null, 4), "saved_facebook", "json");
97+
else alert("Bạn không có mục nào trong saved facebook.");
9698
} catch (e) {
9799
alert("ERROR: " + e);
98100
} finally {

0 commit comments

Comments
 (0)