mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2024-12-31 09:01:56 +01:00
parent
2271477376
commit
5513bcbb61
@ -19,14 +19,35 @@
|
||||
texts.push({text: text.toLowerCase(), content});
|
||||
};
|
||||
scope.search = function(search){
|
||||
search = search.toLowerCase();
|
||||
const result = [];
|
||||
texts.forEach(function(text){
|
||||
if (text.text.indexOf(search) !== -1){
|
||||
result.push(text.content);
|
||||
}
|
||||
const resultSets = search.toLowerCase().split(/\s+/).filter(function(term){
|
||||
return term.trim();
|
||||
}).map(function(term){
|
||||
return new RegExp(term);
|
||||
}).map(function(term){
|
||||
const matching = new Set();
|
||||
texts.forEach(function(text){
|
||||
if (term.test(text.text)){
|
||||
matching.add(text.content);
|
||||
}
|
||||
});
|
||||
return matching;
|
||||
});
|
||||
return result;
|
||||
if (resultSets.length){
|
||||
return Array.from(
|
||||
resultSets.reduce(function(previousSet, set){
|
||||
var andSet = new Set();
|
||||
set.forEach(function(entry){
|
||||
if (previousSet.has(entry)){
|
||||
andSet.add(entry);
|
||||
}
|
||||
});
|
||||
return andSet;
|
||||
})
|
||||
);
|
||||
}
|
||||
else {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
const searchListeners = [];
|
||||
scope.init = function(){
|
||||
|
@ -23,7 +23,22 @@
|
||||
}
|
||||
if (settingDefinition.options){
|
||||
settingDefinition.options.forEach(function(option){
|
||||
messages.push(settingDefinition.name + "_option." + option);
|
||||
if (option !== null){
|
||||
messages.push(settingDefinition.name + "_options." + option);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (settingDefinition.inputs){
|
||||
settingDefinition.inputs.forEach(function(input){
|
||||
if (input){
|
||||
if (input.options){
|
||||
input.options.forEach(function(option){
|
||||
if (option !== null){
|
||||
messages.push(input.name + "_options." + option);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return messages;
|
||||
|
@ -176,11 +176,15 @@
|
||||
search.init()
|
||||
)
|
||||
);
|
||||
const searchOnly = window.location.search === "?searchOnly";
|
||||
if (searchOnly){
|
||||
document.body.classList.add("searching");
|
||||
}
|
||||
search.on(function({search, results, lastResults}){
|
||||
lastResults.forEach(function(node){
|
||||
node.classList.remove("found");
|
||||
});
|
||||
if (search){
|
||||
if (search || searchOnly){
|
||||
document.body.classList.add("searching");
|
||||
results.forEach(function(node){
|
||||
node.classList.add("found");
|
||||
|
@ -12,6 +12,7 @@ Version 0.5.4:
|
||||
- added setting to control if notification details should be stored
|
||||
- state of the arrow for url specific values is saved
|
||||
- browser action icon gets grayed out if the page is whitelisted
|
||||
- added search to options page
|
||||
|
||||
fixes:
|
||||
- window and audio API were always blocked when using any of the "block ..." modes
|
||||
|
Loading…
x
Reference in New Issue
Block a user