Skip to content

Commit 6869ebc

Browse files
committed
new
1 parent a021c88 commit 6869ebc

File tree

12 files changed

+85
-714
lines changed

12 files changed

+85
-714
lines changed

popup/helpers/category.js

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,15 @@ export const CATEGORY = {
3030
vi: `<i class="fa-solid fa-earth-asia fa-shake" style="color:#1F51FF"></i> Tất cả`,
3131
},
3232
},
33-
// available: {
34-
// id: "available",
35-
// showCount: true,
36-
// style: { textDecoration: "underline" },
37-
// name: {
38-
// en: `<i class="fa-solid fa-play fa-beat-fade" style="color:#1F51FF"></i> Available`,
39-
// vi: `<i class="fa-solid fa-play fa-beat-fade" style="color:#1F51FF"></i> Có thể dùng`,
40-
// },
41-
// },
42-
// hot: {
43-
// id: "hot",
44-
// style: { textDecoration: "underline" },
45-
// name: {
46-
// en: `<i class="fa-brands fa-hotjar fa-flip" style="color:#1F51FF;"></i> Hot`,
47-
// vi: `<i class="fa-brands fa-hotjar fa-flip" style="color:#1F51FF;"></i> Nổi bật`,
48-
// },
49-
// },
50-
// new: {
51-
// id: "new",
52-
// style: { textDecoration: "underline" },
53-
// name: {
54-
// en: `<i class="fa-solid fa-solid fa-bolt fa-shake" style="color:#1F51FF"></i> New`,
55-
// vi: `<i class="fa-solid fa-solid fa-bolt fa-shake" style="color:#1F51FF"></i> Mới`,
56-
// },
57-
// },
33+
autorun: {
34+
id: "autorun",
35+
// showCount: true,
36+
style: { textDecoration: "underline" },
37+
name: {
38+
en: `<i class="fa-solid fa-play fa-beat-fade" style="color:#1F51FF"></i> Autorun`,
39+
vi: `<i class="fa-solid fa-play fa-beat-fade" style="color:#1F51FF"></i> Tự động chạy`,
40+
},
41+
},
5842
search: {
5943
id: "search",
6044
name: {

popup/tabs.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import { allScripts as s } from "../scripts/index.js";
22
import { CATEGORY } from "./helpers/category.js";
33
import { favoriteScriptsSaver, recentScriptsSaver } from "./helpers/storage.js";
4+
import { canAutoRun } from "./helpers/utils.js";
45

56
const createTitle = (en, vi) => ({ name: { en, vi } });
67

78
const specialTabs = [
9+
{
10+
...CATEGORY.all,
11+
scripts: [],
12+
},
813
{
914
...CATEGORY.recently,
1015
scripts: [],
@@ -14,7 +19,7 @@ const specialTabs = [
1419
scripts: [],
1520
},
1621
{
17-
...CATEGORY.all,
22+
...CATEGORY.autorun,
1823
scripts: [],
1924
},
2025
];
@@ -224,7 +229,8 @@ const tabs = [
224229
s.reEnableContextMenu,
225230
s.showHiddenFields,
226231
s.studyphim_unlimited,
227-
s.envato_previewBypass,
232+
s.envato_bypassPreview,
233+
s.studocu_bypassPreview,
228234
s.viewCookies,
229235
s.removeCookies,
230236
s.viewBrowserInfo,
@@ -433,6 +439,13 @@ async function refreshSpecialTabs() {
433439

434440
let allTab = specialTabs.find((tab) => tab.id === CATEGORY.all.id);
435441
if (allTab) allTab.scripts = sortScriptsByTab(Object.values(s), tabs);
442+
443+
let autoTab = specialTabs.find((tab) => tab.id === CATEGORY.autorun.id);
444+
if (autoTab)
445+
autoTab.scripts = sortScriptsByTab(
446+
Object.values(s).filter((_) => canAutoRun(_)),
447+
tabs
448+
);
436449
}
437450

438451
function getAllTabs() {

scripts/background-scripts/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import {
99
runScriptInTab,
1010
} from "../helpers/utils.js";
1111

12+
const CACHED = {
13+
runCount: {},
14+
};
15+
1216
chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
1317
console.log("> Received message:", message, sender?.tab?.url);
1418

@@ -25,6 +29,9 @@ async function runScript(event, tab) {
2529
tabId = tab.id,
2630
url = tab.url;
2731

32+
if (!(tabId in CACHED.runCount) || event === Events.onDocumentStart)
33+
CACHED.runCount[tabId] = 0;
34+
2835
for (let script of Object.values(allScripts)) {
2936
try {
3037
if (!checkBlackWhiteList(script, url)) continue;
@@ -38,16 +45,15 @@ async function runScript(event, tab) {
3845
`%c > Run ${script.id} ${funcName} in ${url}`,
3946
"background: #222; color: #bada55"
4047
);
41-
count++;
48+
CACHED.runCount[tabId]++;
4249
}
4350
}
4451
} catch (e) {
4552
console.log("ERROR at script " + script?.id, e);
4653
}
4754
}
4855

49-
updateBadge(tabId, count);
50-
console.log(count);
56+
updateBadge(tabId, CACHED.runCount[tabId]);
5157
}
5258

5359
function updateBadge(tabId, text = "", bgColor = "#666") {

scripts/content-scripts/scripts/instagram.css

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)