1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-03 12:06:31 +02:00

Added search for setting values and urls

For #623
This commit is contained in:
kkapsner 2024-12-21 22:09:53 +01:00
parent 5543d284f9
commit fd7e142681
2 changed files with 30 additions and 1 deletions

View file

@ -14,9 +14,17 @@
const extension = require("./extension");
const texts = [];
const callbacks = [];
scope.register = function(text, content){
texts.push({text: text.toLowerCase(), content});
switch (typeof text){
case "function":
callbacks.push({callback: text, content});
break;
default:
texts.push({text: text.toLowerCase(), content});
break;
}
};
scope.search = function(search){
const resultSets = search.split(/\s+/).filter(function(term){
@ -38,6 +46,11 @@
matching.add(text.content);
}
});
callbacks.forEach(function(callback){
if (callback.callback(term)){
matching.add(callback.content);
}
});
}
return matching;
});