Skip to content

Commit 42bab9a

Browse files
committed
add backup plan
1 parent 49f3a53 commit 42bab9a

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

scripts/ggdrive_downloadVideo.js

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export default {
1414
infoLink:
1515
"https://www.facebook.com/groups/j2team.community/posts/974953859503401/",
1616

17+
changeLogs: {
18+
"2024-07-25": "add backup plan",
19+
},
20+
1721
popupScript: {
1822
onClick: async function () {
1923
const { getCurrentTab, openPopupWithHtml, showLoading } = await import(
@@ -57,6 +61,31 @@ export default {
5761
}
5862
},
5963
},
64+
contentScript: {
65+
onClick_: async () => {
66+
let url = new URL(location.href);
67+
const player_response = url.searchParams.get("player_response");
68+
if (player_response) {
69+
const json = JSON.parse(player_response);
70+
console.log(document.title, json);
71+
72+
const { openPopupWithHtml } = await import("./helpers/utils.js");
73+
openPopupWithHtml(
74+
`<h1>${document.title}</h1>
75+
${json.streamingData.formats
76+
.map((_) => {
77+
return /*html*/ `<div>
78+
<h1><a href="${_.url}" target="_blank">${_.quality}</a></h1>
79+
<video src="${_.url}" controls style="max-width:95%" />
80+
</div>`;
81+
})
82+
.join("<br/>")}`,
83+
700,
84+
700
85+
);
86+
}
87+
},
88+
},
6089
};
6190

6291
export const shared = {
@@ -75,14 +104,15 @@ export const shared = {
75104
// Post: https://www.facebook.com/groups/j2team.community/posts/974953859503401/
76105
getLinkVideoGDriveFromDocId: async function (docid) {
77106
function parse(e) {
78-
var result = {};
79-
return (
80-
e.split("&").forEach(function (e) {
81-
result[decodeURIComponent(e.substring(0, e.indexOf("=")))] =
82-
decodeURIComponent(e.substring(e.indexOf("=") + 1));
83-
}),
84-
result
85-
);
107+
let result = {};
108+
let a = new URLSearchParams(e);
109+
a.entries().forEach((e) => {
110+
result[e[0]] = e[1];
111+
});
112+
return result;
113+
114+
// Array.from(new URLSearchParams("").entries())
115+
// .reduce((total, cur) => ({ ...total, [cur[0]]: cur[1] }), {});
86116
}
87117

88118
function parseStream(e) {
@@ -103,6 +133,10 @@ export const shared = {
103133
let text = await res.text();
104134
let json = parse(text);
105135

136+
if (json?.status === "fail") {
137+
throw Error("FAILED: " + json.reason);
138+
}
139+
106140
json.url_encoded_fmt_stream_map = parseStream(
107141
json.url_encoded_fmt_stream_map
108142
);

working_note.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## 01/07/2024 - ?
44

5+
- [x] Tải video bằng cách record??? <https://chromewebstore.google.com/detail/fetchv-ti%E1%BB%87n-%C3%ADch-m%E1%BB%9F-r%E1%BB%99ng-%C4%91/nfmmmhanepmpifddlkkmihkalkoekpfd> => cannot record full video
6+
57
- [ ] <https://clearthis.page/?u=https://khaidon.substack.com/p/water-washes-clean-a-fable>
68

79
- [ ] good feature - global video speed <https://chromewebstore.google.com/detail/global-speed/jpbjcnkcffbooppibceonlgknpkniiff?hl=en> <https://chromewebstore.google.com/detail/video-speed-controller/nffaoalbilbmmfgbnbgppjihopabppdk?hl=en>

0 commit comments

Comments
 (0)