Skip to content

Commit bf619bc

Browse files
committed
hot tab, new tab, fix, update
1 parent 3e3d1db commit bf619bc

File tree

10 files changed

+342
-149
lines changed

10 files changed

+342
-149
lines changed

backup/scripts.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,3 +419,75 @@ javascript: (() => {
419419
console.log("Done"), location.reload();
420420
});
421421
})();
422+
423+
function getLinkFCode() {
424+
function getDataDownload(linkcode, retry = 1) {
425+
let info = {
426+
linkcode: [linkcode],
427+
withFcode5: 0,
428+
fcode: "",
429+
};
430+
let Authorization = "Bearer " + $("input#acstk").attr("data-value");
431+
if (retry < 5) {
432+
$.ajax({
433+
url: "/api/v3/downloads/download-side-by-side",
434+
type: "POST",
435+
contentType: "application/json",
436+
data: JSON.stringify(info),
437+
dataType: "json",
438+
headers: { Authorization: Authorization },
439+
success: function (xhr, status, error) {
440+
// ctrl.StatusDownload = true;
441+
// ctrl.showModelDowload(true);
442+
// ctrl.downloadMulti = xhr;
443+
// ctrl.StatusDownload = true;
444+
// ctrl.selectedFileDownload[id]["donwloaded"] = true;
445+
// donwloaded
446+
// ctrl.startDownload1by1_1(ctrl.downloadMulti, id);
447+
448+
console.log(xhr, status, error);
449+
},
450+
error: function (error, textStatus) {
451+
if (textStatus === "timeout") {
452+
console.log("Retrying ...", retry);
453+
getDataDownload(linkcode, ++retry);
454+
return false;
455+
} else if (error.status == 401) {
456+
return alert("You need a VIP account to do this.");
457+
}
458+
alert(error.responseJSON.errors);
459+
},
460+
timeout: 1000,
461+
});
462+
} else {
463+
$.ajax({
464+
type: "POST",
465+
url: "/api/v3/downloads/download-side-by-side",
466+
contentType: "application/json",
467+
data: JSON.stringify(info),
468+
dataType: "json",
469+
beforeSend: function (request) {
470+
request.setRequestHeader("Authorization", Authorization);
471+
},
472+
success: function (xhr, status, error) {
473+
// ctrl.StatusDownload = true;
474+
// ctrl.showModelDowload(true);
475+
// ctrl.downloadMulti = xhr;
476+
// ctrl.StatusDownload = true;
477+
// ctrl.selectedFileDownload[id]['donwloaded'] = true;
478+
// donwloaded
479+
// ctrl.startDownload1by1_1(ctrl.downloadMulti,id);
480+
console.log(xhr, status, error);
481+
},
482+
error: function (error) {
483+
if (error.status == 401) {
484+
return alert("You need a VIP account to do this.");
485+
}
486+
alert(error.responseJSON.errors);
487+
},
488+
});
489+
}
490+
}
491+
492+
getDataDownload($("#linkcode").attr("value"));
493+
}

popup/helpers/badge.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,25 @@ export const addBadge = (script, ...badges) => ({ ...script, badges: badges });
22

33
export const BADGES = {
44
hot: {
5+
id: "hot",
56
text: { en: "hot", vi: "hot" },
67
color: "#fff",
78
backgroundColor: "#d40",
89
},
910
beta: {
11+
id: "beta",
1012
text: { en: "beta", vi: "beta" },
1113
color: "#000",
1214
backgroundColor: "#dd0",
1315
},
1416
new: {
17+
id: "new",
1518
text: { en: "new", vi: "mới" },
1619
color: "#fff",
1720
backgroundColor: "#44d",
1821
},
1922
unstable: {
23+
id: "unstable",
2024
text: { en: "unstable", vi: "chưa ổn định" },
2125
color: "#fff",
2226
backgroundColor: "#a77",

popup/helpers/category.js

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ export const CATEGORY = {
2424
vi: `<i class="fa-solid fa-play fa-beat-fade" style="color:#1F51FF"></i> Có thể dùng`,
2525
},
2626
},
27+
hot: {
28+
id: "hot",
29+
style: { textDecoration: "underline" },
30+
name: {
31+
en: `<i class="fa-brands fa-hotjar" style="color:#1F51FF"></i> Hot`,
32+
vi: `<i class="fa-brands fa-hotjar" style="color:#1F51FF"></i> Nổi bật`,
33+
},
34+
},
35+
new: {
36+
id: "new",
37+
style: { textDecoration: "underline" },
38+
name: {
39+
en: `<i class="fa-solid fa-apple-whole" style="color:#1F51FF"></i> New`,
40+
vi: `<i class="fa-solid fa-apple-whole" style="color:#1F51FF"></i> Mới`,
41+
},
42+
},
2743
search: {
2844
id: "search",
2945
name: {
@@ -74,20 +90,6 @@ export const CATEGORY = {
7490
},
7591
},
7692
doutube: { id: "doutube", name: { en: "Doutu.be", vi: "Doutu.be" } },
77-
pdf: {
78-
id: "pdf",
79-
name: {
80-
en: `<i class="fa-solid fa-file-pdf"></i> PDF`,
81-
vi: `<i class="fa-solid fa-file-pdf"></i> PDF`,
82-
},
83-
},
84-
qrcode: {
85-
id: "qrcode",
86-
name: {
87-
en: `<i class="fa-solid fa-qrcode"></i> QR Code`,
88-
vi: `<i class="fa-solid fa-qrcode"></i> QR Code`,
89-
},
90-
},
9193
automation: {
9294
id: "automation",
9395
name: {
@@ -116,13 +118,6 @@ export const CATEGORY = {
116118
vi: `<i class="fa-solid fa-eye"></i> Giao diện`,
117119
},
118120
},
119-
more: {
120-
id: "more",
121-
name: {
122-
en: `<i class="fa-solid fa-ellipsis"></i> More`,
123-
vi: `<i class="fa-solid fa-ellipsis"></i> Khác`,
124-
},
125-
},
126121
recommend: {
127122
id: "recommend",
128123
style: { textDecoration: "underline" },

popup/tabs.js

Lines changed: 57 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ const specialTabs = [
1818
...CATEGORY.favorite,
1919
scripts: [],
2020
},
21+
{
22+
...CATEGORY.hot,
23+
scripts: [],
24+
},
25+
{
26+
...CATEGORY.new,
27+
scripts: [],
28+
},
2129
{
2230
...CATEGORY.available,
2331
scripts: [],
@@ -137,17 +145,16 @@ const tabs = [
137145
s.doutube_getAllVideoInUserProfile,
138146
],
139147
},
140-
{
141-
...CATEGORY.pdf,
142-
scripts: [s.darkModePDF, s.webToPDF],
143-
},
144-
{
145-
...CATEGORY.qrcode,
146-
scripts: [s.textToQRCode, s.webToQRCode],
147-
},
148148
{
149149
...CATEGORY.automation,
150-
scripts: [s.getAllEmailsInWeb, s.performanceAnalyzer, s.scrollToVeryEnd],
150+
scripts: [
151+
s.textToQRCode,
152+
s.webToQRCode,
153+
s.getAllEmailsInWeb,
154+
s.performanceAnalyzer,
155+
s.scrollToVeryEnd,
156+
s.webToPDF,
157+
],
151158
},
152159
{
153160
...CATEGORY.password,
@@ -160,6 +167,7 @@ const tabs = [
160167
{
161168
...CATEGORY.unlock,
162169
scripts: [
170+
s.shortenURL,
163171
s.unshorten,
164172
s.showHiddenFields,
165173
s.viewCookies,
@@ -173,8 +181,10 @@ const tabs = [
173181
{
174182
...CATEGORY.webUI,
175183
scripts: [
184+
s.darkModePDF,
176185
s.toggleEditPage,
177186
s.scrollByDrag,
187+
s.runStatJs,
178188
createTitle("--- View ---", "--- Xem ---"),
179189
s.listAllImagesInWeb,
180190
s.viewAllLinks,
@@ -197,10 +207,6 @@ const tabs = [
197207
s.letItSnow,
198208
],
199209
},
200-
{
201-
...CATEGORY.more,
202-
scripts: [s.shortenURL, s.runStatJs, s.test_script],
203-
},
204210
];
205211

206212
const recommendTab = {
@@ -371,30 +377,37 @@ const recommendTab = {
371377
],
372378
};
373379

374-
// add recently and available to head of array
375-
async function getAvailableScriptsInTabs(_tabs) {
380+
function sortScriptsByTab(scripts, _tabs, addTabTitle = true) {
376381
let result = [];
377-
const avai = await getAvailableScripts();
378382

379383
for (let tab of Object.values(_tabs)) {
380-
let avaiScriptsInTab = [];
384+
let sorted = [];
381385

382386
for (let script of tab.scripts) {
383-
let isAvai = avai.findIndex((_) => _.id === script.id) >= 0;
384-
if (isAvai) {
385-
avaiScriptsInTab.push(script);
387+
let found = scripts.findIndex((_) => _.id === script.id) >= 0;
388+
if (found) {
389+
sorted.push(script);
386390
}
387391
}
388392

389-
if (avaiScriptsInTab.length) {
390-
result.push(createTitle(tab.name.en, tab.name.vi));
391-
result.push(...avaiScriptsInTab);
393+
if (sorted.length) {
394+
addTabTitle && result.push(createTitle(tab.name.en, tab.name.vi));
395+
result.push(...sorted);
392396
}
393397
}
394-
395398
return result;
396399
}
397400

401+
async function getAvailableScriptsInTabs(_tabs) {
402+
return sortScriptsByTab(await getAvailableScripts(), _tabs);
403+
}
404+
405+
function getScriptsWithBadgeId(scripts, badgeId) {
406+
return scripts.filter((script) =>
407+
script.badges?.find((_) => _.id === badgeId)
408+
);
409+
}
410+
398411
async function refreshSpecialTabs() {
399412
// add data to special tabs
400413
let recentTab = specialTabs.find((tab) => tab.id === CATEGORY.recently.id);
@@ -403,8 +416,26 @@ async function refreshSpecialTabs() {
403416
let favoriteTab = specialTabs.find((tab) => tab.id === CATEGORY.favorite.id);
404417
if (favoriteTab) favoriteTab.scripts = await favoriteScriptsSaver.get();
405418

406-
let avaiab = specialTabs.find((tab) => tab.id === CATEGORY.available.id);
407-
if (avaiab) avaiab.scripts = await getAvailableScriptsInTabs(tabs);
419+
let avaiTab = specialTabs.find((tab) => tab.id === CATEGORY.available.id);
420+
if (avaiTab) avaiTab.scripts = await getAvailableScriptsInTabs(tabs);
421+
422+
// ==== special badge tab ====
423+
let allScriptsArr = Object.values(s);
424+
console.log(allScriptsArr);
425+
426+
let hotTab = specialTabs.find((tab) => tab.id === CATEGORY.hot.id);
427+
if (hotTab)
428+
hotTab.scripts = sortScriptsByTab(
429+
getScriptsWithBadgeId(allScriptsArr, BADGES.hot.id),
430+
tabs
431+
);
432+
433+
let newTab = specialTabs.find((tab) => tab.id === CATEGORY.new.id);
434+
if (newTab)
435+
newTab.scripts = sortScriptsByTab(
436+
getScriptsWithBadgeId(allScriptsArr, BADGES.new.id),
437+
tabs
438+
);
408439
}
409440

410441
function getAllTabs() {

scripts/checkWebDie.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export default {
2-
icon: `https://downforeveryoneorjustme.com/favicon.ico`,
2+
icon: `https://s2.googleusercontent.com/s2/favicons?domain=downforeveryoneorjustme.com`,
33
name: {
44
en: "Dowfor - Check web die",
55
vi: "Dowfor - Kiểm tra web die",

scripts/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ import getFavicon from "./getFavicon.js";
105105
import fb_getTokenLocmai from "./fb_getTokenLocmai.js";
106106
import fb_checkToken from "./fb_checkToken.js";
107107
import fb_getTokenCampaigns from "./fb_getTokenCampaigns.js";
108-
import test_script from "./test_script.js";
109108
import unshorten from "./unshorten.js";
110109

111110
// inject badges
@@ -222,7 +221,6 @@ const allScripts = {
222221
fb_checkToken: addBadge(fb_checkToken, BADGES.new),
223222
fb_getTokenCampaigns: addBadge(fb_getTokenCampaigns, BADGES.new),
224223
unshorten: addBadge(unshorten, BADGES.hot),
225-
test_script: test_script,
226224
};
227225

228226
// inject id to all scripts

0 commit comments

Comments
 (0)