-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
screenshotVisiblePage.js
84 lines (78 loc) · 2.08 KB
/
screenshotVisiblePage.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { UfsGlobal } from "./content-scripts/ufs_global.js";
import {
attachDebugger,
detachDebugger,
getCurrentTab,
sendDevtoolCommand,
showLoading,
} from "./helpers/utils.js";
export default {
icon: '<i class="fa-solid fa-camera fa-lg"></i>',
name: {
en: "Screenshot webpage",
vi: "Chụp ảnh web",
},
description: {
en: "Taking a screenshot of visible webpage (bypass websites that block screenshots such as Netflix, ...)",
vi: "Chụp ảnh trang web hiện tại (bypass những trang web cấm chụp màn hình như Netflix,...)",
},
buttons: [
{
icon: '<i class="fa-solid fa-question"></i>',
name: {
vi: "Cách cấm chụp màn hình hoạt động?",
en: "How these web prevent screenshot?",
},
onClick: () => {
window.open(
"https://www.google.com/search?q=Stream+DRM+la+gi",
"_blank"
);
},
},
{
icon: '<i class="fa-solid fa-arrow-up-right-from-square"></i>',
name: {
vi: "Web ví dụ",
en: "Example web",
},
onClick: () => {
window.open(
"https://www.theoplayer.com/theoplayer-drm-aes-128-encryption",
"_blank"
);
},
},
],
changeLogs: {
"2024-06-10": "init",
},
popupScript: {
onClick: async function () {
const { setLoadingText, closeLoading } = showLoading(
"Đang tạo ảnh chụp màn hình..."
);
try {
let tab = await getCurrentTab();
await attachDebugger(tab);
let img = await sendDevtoolCommand(tab, "Page.captureScreenshot", {
format: "png",
quality: 100,
fromSurface: true,
captureBeyondViewport: false,
});
console.log(img);
setLoadingText("Đang lưu ảnh...");
UfsGlobal.Extension.download({
url: "data:image/png;base64," + img.data,
filename: "webpage.png",
});
await detachDebugger(tab);
} catch (e) {
alert("Lỗi: " + e);
} finally {
closeLoading();
}
},
},
};