MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / setEnableForAllTab

Function setEnableForAllTab

scripts/smoothScroll.js:64–110  ·  view source on GitHub ↗
(enable)

Source from the content-addressed store, hash-verified

62};
63
64async function setEnableForAllTab(enable) {
65 const { t } = await import("../popup/helpers/lang.js");
66 const { runScriptInTab, getAllTabs: getAllAvailableTabs } = await import(
67 "./helpers/utils.js"
68 );
69 const tabs = await getAllAvailableTabs();
70 let count = 0;
71 for (let tab of tabs) {
72 try {
73 runScriptInTab({
74 target: {
75 tabId: tab.id,
76 allFrames: true,
77 },
78 func: enable
79 ? enableSmoothScroll
80 : () => {
81 window.ufs_smoothScroll_disable?.();
82 },
83 world: "ISOLATED",
84 });
85 count++;
86 } catch (e) {
87 console.error(e);
88 }
89 }
90 let text = enable
91 ? { vi: "Bật", en: "Enabled" }
92 : { vi: "Tắt", en: "Disabled" };
93
94 if (count)
95 await Swal.fire({
96 icon: "success",
97 title: t({
98 vi: "Đã " + text.vi + " Cuộn chuột Siêu mượt",
99 en: "Super smooth scroll " + text.en,
100 }),
101 html: t({
102 vi:
103 `Đã tự ${text.vi} cho ${count} tab đang mở<br/><br/>` +
104 "Bạn có thể dùng ngay không cần tải lại trang.",
105 en:
106 `${text.en} smooth scroll for ${count} opening tabs<br/><br/>` +
107 "Dont need to reload websites.",
108 }),
109 });
110}
111
112// TODO:
113// [ ] setting page

Callers 1

smoothScroll.jsFile · 0.85

Calls 3

errorMethod · 0.80
runScriptInTabFunction · 0.50
tFunction · 0.50

Tested by

no test coverage detected