mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-03 12:06:31 +02:00
parent
5543d284f9
commit
fd7e142681
2 changed files with 30 additions and 1 deletions
|
@ -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;
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue