Skip to content

Commit b906693

Browse files
committed
update doutube
1 parent d976906 commit b906693

File tree

6 files changed

+47
-18
lines changed

6 files changed

+47
-18
lines changed

popup/helpers/category.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export const CATEGORY = {
9696
vi: `<i class="fa-brands fa-github"></i> Github`,
9797
},
9898
},
99-
doutube: { id: "doutube", name: { en: "Doutu.be", vi: "Doutu.be" } },
10099
automation: {
101100
id: "automation",
102101
name: {

popup/tabs.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,21 +135,20 @@ const tabs = [
135135
},
136136
{
137137
...CATEGORY.tiktok,
138-
scripts: [s.tiktok_downloadVideo, s.douyin_downloadVideo],
139-
},
140-
{
141-
...CATEGORY.github,
142-
scripts: [s.github_goToFirstCommit, s.githubdev, s.github1s],
143-
},
144-
{
145-
...CATEGORY.doutube,
146138
scripts: [
139+
s.tiktok_downloadVideo,
140+
s.douyin_downloadVideo,
141+
createTitle("--- Doutu.be ---", "--- Doutu.be ---"),
147142
s.doutube_enableDownloadVideo,
148143
s.doutube_downloadWatchingVideo,
149144
s.doutube_downloadWatchingStory,
150145
s.doutube_getAllVideoInUserProfile,
151146
],
152147
},
148+
{
149+
...CATEGORY.github,
150+
scripts: [s.github_goToFirstCommit, s.githubdev, s.github1s],
151+
},
153152
{
154153
...CATEGORY.automation,
155154
scripts: [

scripts/doutube_downloadWatchingVideo.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,16 @@ export default {
2020
rect.top < window.innerHeight
2121
);
2222
};
23-
for (let v of Array.from(document.querySelectorAll("video")))
24-
if (isElementInViewport(v) && v.src) return window.open(v.src);
23+
for (let v of Array.from(document.querySelectorAll("video"))) {
24+
if (isElementInViewport(v)) {
25+
if (v.src) return window.open(v.src);
26+
27+
let sources = Array.from(v.querySelectorAll("source"));
28+
for (let s of sources) {
29+
if (s.src) return window.open(s.src);
30+
}
31+
}
32+
}
2533
alert(
2634
"Không tìm thấy video nào, hãy scroll tới khi nào video tự động phát rồi ấn lại bookmark nhé."
2735
);

scripts/doutube_getAllVideoInUserProfile.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ export default {
1111
whiteList: ["*://doutu.be"],
1212

1313
func: async function () {
14+
// https://stackoverflow.com/a/18197341/11898496
15+
function download(filename, text) {
16+
var element = document.createElement("a");
17+
element.setAttribute(
18+
"href",
19+
"data:text/plain;charset=utf-8," + encodeURIComponent(text)
20+
);
21+
element.setAttribute("download", filename);
22+
element.style.display = "none";
23+
document.body.appendChild(element);
24+
element.click();
25+
document.body.removeChild(element);
26+
}
27+
1428
const WAIT_FOR_FULL_VIDEO_LOADED = 5000;
1529
const FIND_FULL_VIDEO_INTERVAL = 100;
1630
const sleep = (m) => new Promise((r) => setTimeout(r, m));
@@ -20,7 +34,15 @@ export default {
2034
const closeFullVideo = () =>
2135
document.querySelector("div.top-8.left-4")?.click();
2236

23-
alert("Getting video, open console (F12) to see result.");
37+
if (
38+
!confirm(
39+
"Tool sẽ tự động mở từng ảnh/video để lấy link.\nVui lòng không thoát trang web.\nBấm OK để bắt đầu quá trình lấy link."
40+
)
41+
) {
42+
return;
43+
}
44+
45+
let allUrls = [];
2446

2547
const queue = getAllVideo();
2648
while (queue.length > 0) {
@@ -38,6 +60,7 @@ export default {
3860
}
3961

4062
if (full_video) {
63+
allUrls.push(full_video.src);
4164
console.log(full_video.src);
4265
} else {
4366
console.log("Not found full video");
@@ -46,5 +69,9 @@ export default {
4669
closeFullVideo();
4770
await sleep(500);
4871
}
72+
73+
console.log(allUrls);
74+
alert("Tìm được " + allUrls.length + " videos. Bấm ok để tải xuống link.");
75+
download(location.pathname + ".txt", allUrls.join("\n"));
4976
},
5077
};

scripts/douyin_downloadVideo.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ export default {
2424
<div style="margin:auto;background:#eee;position:relative;padding:20px;overflow:auto;max-height:90vh;">
2525
${videos
2626
.map((video) => {
27-
return (
28-
`<video controls style="max-width:50vw">` +
29-
video.innerHTML +
30-
`</video>`
31-
);
27+
return `<video controls style="max-width:50vw">${video.innerHTML}</video>`;
3228
})
3329
.join("<br/>")}
3430
<button

scripts/showTheImages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default {
6565
<th colspan="2">Found ${L.length} Image(s):</th>
6666
</tr>
6767
68-
<div style="padding:20px;border:0;outline:0">
68+
<div style="padding:20px;border:0;outline:0;background:#eee">
6969
${L.map(
7070
(img) => '<img src="' + img + '" style="margin:5px"/>'
7171
).join("")}

0 commit comments

Comments
 (0)