Skip to content

Commit d6c64ec

Browse files
committed
preview
1 parent 3212d69 commit d6c64ec

File tree

7 files changed

+44
-17
lines changed

7 files changed

+44
-17
lines changed

index.html

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,8 @@
88
</head>
99

1010
<body>
11-
<a href="https://google.com">google.com</a>
12-
13-
<iframe src="https://example.com" frameborder="0"></iframe>
14-
15-
<img src="https://picsum.photos/200/300" alt="">
16-
1711
<script>
18-
let a = document.querySelector('a');
19-
a.onclick = (e) => {
20-
e.preventDefault();
21-
window.open("https://example.com")
22-
}
12+
window.location.href = "https://hoangtran0410.github.io/useful-script/popup/popup.html"
2313
</script>
2414
</body>
2515

popup/index.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ function createScriptButton(script, isFavorite = false) {
176176
const checkmark = document.createElement("button");
177177
checkmark.className = "checkmark";
178178
checkmark.onclick = async (e) => {
179+
if (checkIsPreview(script)) return;
180+
179181
let oldVal = await isActiveScript(script.id);
180182
let newVal = !oldVal;
181183

@@ -447,7 +449,39 @@ function showError(e) {
447449
});
448450
}
449451

452+
function checkIsPreview(script) {
453+
if (
454+
location.hostname === "hoangtran0410.github.io" ||
455+
location.hostname === "127.0.0.1"
456+
) {
457+
trackEvent("CLICK_PREVIEW_" + script.id);
458+
Swal.fire({
459+
icon: "info",
460+
title: t({ vi: "Đây là bản xem trước", en: "This is a preview" }),
461+
text: t({
462+
vi: "Vui lòng tải và cài đặt tiện ích Useful-script để sử dung chức năng này nhé",
463+
en: "Please install Useful-script extension to use these features",
464+
}),
465+
confirmButtonText: t({ vi: "Xem hướng dẫn", en: "View tutorial" }),
466+
cancelButtonText: t({ vi: "Đã hiểu", en: "Ok" }),
467+
showCancelButton: true,
468+
reverseButtons: true,
469+
}).then((res) => {
470+
if (res.isConfirmed) {
471+
window.open(
472+
"https://www.facebook.com/groups/1154059318582088/posts/1453443235310360/",
473+
"_blank"
474+
);
475+
}
476+
});
477+
return true;
478+
}
479+
return false;
480+
}
481+
450482
async function runScript(script) {
483+
if (checkIsPreview(script)) return;
484+
451485
let tab = await getCurrentTab();
452486
let willRun = checkBlackWhiteList(script, tab.url);
453487
if (willRun) {

popup/popup.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
<body>
2323
<div class="popup-header">Useful Scripts</div>
2424
<h3>
25-
<a data-track="donate" target="_blank"
26-
href="https://github.com/HoangTran0410/HoangTran0410/blob/main/DONATE.md">
25+
<a data-track="donate" target="_blank" href="https://hoangtran0410.github.io/HoangTran0410/DONATE">
2726
<i class="fa-solid fa-mug-saucer"></i> donate
2827
</a>
2928
<a data-track="github" target="_blank" href="https://github.com/HoangTran0410/useful-script">

scripts/@index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// https://stackoverflow.com/a/59002206
22

3-
export { default as test } from "./@test.js";
3+
export { default as test } from "./test.js";
44
export { default as fb_toggleLight } from "./fb_toggleLight.js";
55
export { default as fb_getTokenFacebook } from "./fb_getTokenFacebook.js";
66
export { default as fb_getUid } from "./fb_getUid.js";
@@ -137,7 +137,7 @@ export { default as magnify_image } from "./magnify_image.js";
137137
export { default as auto_redirectLargestImageSrc } from "./auto_redirectLargestImageSrc.js";
138138
export { default as textToQrCode } from "./textToQrCode.js";
139139
export { default as insta_anonymousStoryViewer } from "./insta_anonymousStoryViewer.js";
140-
export { default as ufs_statistic } from "./@ufs_statistic.js";
140+
export { default as ufs_statistic } from "./ufs_statistic.js";
141141
export { default as pip_fullWebsite } from "./pip_fullWebsite.js";
142142
export { default as similarWeb_bypassLimit } from "./similarWeb_bypassLimit.js";
143143
export { default as pip_canvas } from "./pip_canvas.js";
File renamed without changes.
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async function onDocumentEnd() {
4949
const container = document.createElement("div");
5050

5151
if (hasLog) {
52-
UfsGlobal.Extension.getURL("/scripts/@ufs_statistic.css").then(
52+
UfsGlobal.Extension.getURL("/scripts/ufs_statistic.css").then(
5353
UfsGlobal.DOM.injectCssFile
5454
);
5555

@@ -311,6 +311,9 @@ async function onDocumentEnd() {
311311
const logByUidSorted = new Map(
312312
[...logByUid.entries()].sort((a, b) => b[1] - a[1])
313313
);
314+
const fbUsers = [...logByUid.entries()].filter(([key, value]) => {
315+
return isFbUid(key);
316+
});
314317

315318
const canvas_uid = document.createElement("canvas");
316319
const ctx4 = canvas_uid.getContext("2d");
@@ -399,7 +402,8 @@ async function onDocumentEnd() {
399402
${eventNameCount.size} unique events<br/><br/>
400403
${scriptUsedTotalCount} scripts used (~${_scriptsPerHour} scripts/hour)<br/>
401404
${scriptsUsed.size} unique scripts<br/><br/>
402-
${logByUid.size} unique users`;
405+
${logByUid.size} unique users<br/>
406+
${fbUsers.length} facebook users`;
403407

404408
// ======================== Append Charts ========================
405409
container.prepend(

0 commit comments

Comments
 (0)