mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-22 12:50:36 +01:00
parent
5543d284f9
commit
fd7e142681
@ -14,9 +14,17 @@
|
||||
|
||||
const extension = require("./extension");
|
||||
const texts = [];
|
||||
const callbacks = [];
|
||||
|
||||
scope.register = function(text, 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;
|
||||
});
|
||||
|
@ -576,6 +576,22 @@
|
||||
settingStrings.getStrings(setting).forEach(function(string){
|
||||
search.register(string, row);
|
||||
});
|
||||
if (setting.get){
|
||||
search.register(function(term){
|
||||
if (term.test(setting.get())){
|
||||
return true;
|
||||
}
|
||||
if (setting.urlSpecific){
|
||||
return setting.urlContainer.get().some(function(urlSetting){
|
||||
if (urlSetting.hasOwnProperty(setting.name)){
|
||||
return term.test(urlSetting.url) || term.test(urlSetting[setting.name]);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}, row);
|
||||
}
|
||||
section.addRow(row);
|
||||
|
||||
setupComputeDependenciesForDisplay(setting, section, row);
|
||||
|
Loading…
x
Reference in New Issue
Block a user