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

Function initSearch

popup/index.js:1081–1108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1079}
1080
1081function initSearch() {
1082 searchInput.addEventListener("input", (event) => {
1083 let keyword = event.target.value;
1084 let found = 0;
1085 let childrens = document.querySelectorAll(".tabcontent .buttonContainer");
1086
1087 childrens.forEach((child) => {
1088 let willShow = true;
1089 let text = removeAccents(child.textContent).toLowerCase();
1090 let searchStr = removeAccents(keyword)
1091 .toLowerCase()
1092 .split(" ")
1093 .filter((_) => _);
1094
1095 for (let s of searchStr) {
1096 if (text.indexOf(s) == -1) {
1097 willShow = false;
1098 break;
1099 }
1100 }
1101 child.classList.toggle("hide", !willShow);
1102 if (willShow) found++;
1103 });
1104 searchFound.innerText = keyword
1105 ? `${found}/${childrens.length} scripts`
1106 : "";
1107 });
1108}
1109
1110function initTracking() {
1111 let trackingEles = document.querySelectorAll("[data-track]");

Callers 1

index.jsFile · 0.85

Calls 2

removeAccentsFunction · 0.90
filterMethod · 0.80

Tested by

no test coverage detected