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

Function sortScriptsByTab

popup/tabs.js:381–398  ·  view source on GitHub ↗
(scripts, _tabs, addTabTitle = true)

Source from the content-addressed store, hash-verified

379};
380
381function sortScriptsByTab(scripts, _tabs, addTabTitle = true) {
382 let result = [];
383
384 for (let tab of Object.values(_tabs)) {
385 let sorted = [];
386
387 for (let script of tab.scripts) {
388 let found = scripts.findIndex((_) => _.id === script.id) >= 0;
389 if (found) sorted.push(script);
390 }
391
392 if (sorted.length) {
393 addTabTitle && result.push(createTitle(tab.name.en, tab.name.vi));
394 result.push(...sorted);
395 }
396 }
397 return result;
398}
399
400const allScriptInTabs = [
401 ...tabs.map((tab) => tab.scripts),

Callers 1

refreshSpecialTabsFunction · 0.85

Calls 1

createTitleFunction · 0.85

Tested by

no test coverage detected