MCPcopy Index your code
hub / github.com/hoothin/UserScripts / searchByInput

Function searchByInput

DownloadAllContent/DownloadAllContent.user.js:2057–2092  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2055 let searchInput = document.createElement("input");
2056 let inputTimer;
2057 function searchByInput() {
2058 clearTimeout(inputTimer);
2059 inputTimer = setTimeout(() => {
2060 let curValue = searchInput.value;
2061 let matchRules = [];
2062 let dontMatchRules = [];
2063 if (curValue) {
2064 for (let i = 0; i < ruleList.children.length; i++) {
2065 let curRule = ruleList.children[i];
2066 let aHref = curRule.firstChild.href;
2067 if (aHref.indexOf(curValue) == -1) {
2068 dontMatchRules.push(curRule);
2069 } else {
2070 matchRules.push(curRule);
2071 }
2072 }
2073 } else {
2074 dontMatchRules = ruleList.children;
2075 }
2076 if (matchRules.length) {
2077 for (let i = 0; i < dontMatchRules.length; i++) {
2078 let curRule = dontMatchRules[i];
2079 curRule.style.display = "none";
2080 }
2081 for (let i = 0; i < matchRules.length; i++) {
2082 let curRule = matchRules[i];
2083 curRule.style.display = "";
2084 }
2085 } else {
2086 for (let i = 0; i < dontMatchRules.length; i++) {
2087 let curRule = dontMatchRules[i];
2088 curRule.style.display = "";
2089 }
2090 }
2091 }, 500);
2092 }
2093 searchInput.style.margin = "10px";
2094 searchInput.style.width = "100%";
2095 searchInput.placeholder = i18n.searchRule;

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected