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

Function createTabContent

popup/index.js:176–213  ·  view source on GitHub ↗
(tab)

Source from the content-addressed store, hash-verified

174}
175
176async function createTabContent(tab) {
177 // search bar
178 let scriptsCount = tab.scripts.filter((_) => !isTitle(_)).length;
179 let name = t(tab.name).replace(/<i(.*?)<\/i> /g, "");
180 searchInput.value = "";
181 searchInput.placeholder = t({
182 vi: `Tìm trong ${scriptsCount} chức năng ${name}...`,
183 en: `Search in ${scriptsCount} scripts ${name}...`,
184 });
185 // searchInput.focus?.();
186
187 // create tab content
188 const contentContainer = document.createElement("div");
189 contentContainer.className = "tabcontent";
190
191 // create button for scripts in tabcontent
192 if (!tab.scripts?.length) {
193 const emptyText = document.createElement("h3");
194 emptyText.style.padding = "30px 0";
195 emptyText.innerHTML = t(
196 tab.placeholder || {
197 en: `<i class="fa-solid fa-circle-info"></i> Nothing here yet...`,
198 vi: `<i class="fa-solid fa-circle-info"></i> Chưa có gì ở đây hết...`,
199 }
200 );
201 contentContainer.appendChild(emptyText);
202 } else {
203 const favoriteScriptIds = favoriteScriptsSaver.getIds();
204 tab.scripts.forEach((script) => {
205 let isFavorite = favoriteScriptIds.find((id) => script.id === id);
206 contentContainer.appendChild(createScriptButton(script, isFavorite));
207 });
208 }
209
210 // inject to DOM
211 contentDiv.innerHTML = "";
212 contentDiv.appendChild(contentContainer);
213}
214
215function createScriptButton(script, isFavorite = false) {
216 // Section title

Callers 1

openTabFunction · 0.85

Calls 5

isTitleFunction · 0.90
tFunction · 0.90
createScriptButtonFunction · 0.85
filterMethod · 0.80
replaceMethod · 0.80

Tested by

no test coverage detected