exact matching preference; fixes #26
This commit is contained in:
parent
e51d174079
commit
62d3eefd67
3 changed files with 24 additions and 3 deletions
21
common.js
21
common.js
|
@ -14,7 +14,8 @@ var prefs = {
|
|||
custom: {},
|
||||
mode: 'blacklist',
|
||||
color: '#ffa643',
|
||||
cache: true
|
||||
cache: true,
|
||||
exactMatch: false
|
||||
};
|
||||
chrome.storage.local.get(prefs, ps => {
|
||||
Object.assign(prefs, ps);
|
||||
|
@ -160,13 +161,27 @@ function match({url, tabId}) {
|
|||
if (prefs.mode === 'blacklist') {
|
||||
if (prefs.blacklist.length) {
|
||||
const h = hostname(url);
|
||||
return prefs.blacklist.some(s => s === h);
|
||||
return prefs.blacklist.some(s => () => {
|
||||
if (s === h) {
|
||||
return true;
|
||||
}
|
||||
else if (prefs.exactMatch === false) {
|
||||
return s.endsWith(h) || h.endsWith(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else if (prefs.mode === 'whitelist') {
|
||||
if (prefs.whitelist.length) {
|
||||
const h = hostname(url);
|
||||
return prefs.whitelist.some(s => s === h) === false;
|
||||
return prefs.whitelist.some(s => {
|
||||
if (s === h) {
|
||||
return true;
|
||||
}
|
||||
else if (prefs.exactMatch === false) {
|
||||
return s.endsWith(h) || h.endsWith(s);
|
||||
}
|
||||
}) === false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
|
|
|
@ -45,6 +45,9 @@
|
|||
<tr>
|
||||
<td><label><input type="checkbox" id="cache"> Use caching to improve performance (recommended value is true). Uncheck this option only if you are using the custom mode and also you need the user-agent string to be altered from the provided list on every single request.</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label><input type="checkbox" id="exactMatch"> Use exact matching (if checked, you will need to insert all sub-domains in the white-list and black-list modes to be considered. If unchecked, all the sub-domains are passing the matching condition (e.g: www.google.com passes the matching if google.com is in the list))</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label><input type="checkbox" id="faqs"> Open FAQs page on updates</label></td>
|
||||
</tr>
|
||||
|
|
|
@ -29,6 +29,7 @@ function save() {
|
|||
}
|
||||
|
||||
chrome.storage.local.set({
|
||||
exactMatch: document.getElementById('exactMatch').checked,
|
||||
faqs: document.getElementById('faqs').checked,
|
||||
cache: document.getElementById('cache').checked,
|
||||
blacklist: prepare(document.getElementById('blacklist').value),
|
||||
|
@ -43,6 +44,7 @@ function save() {
|
|||
|
||||
function restore() {
|
||||
chrome.storage.local.get({
|
||||
exactMatch: false,
|
||||
faqs: true,
|
||||
cache: true,
|
||||
mode: 'blacklist',
|
||||
|
@ -50,6 +52,7 @@ function restore() {
|
|||
blacklist: [],
|
||||
custom: {}
|
||||
}, prefs => {
|
||||
document.getElementById('exactMatch').checked = prefs.exactMatch;
|
||||
document.getElementById('faqs').checked = prefs.faqs;
|
||||
document.getElementById('cache').checked = prefs.cache;
|
||||
document.querySelector(`[name="mode"][value="${prefs.mode}"`).checked = true;
|
||||
|
|
Loading…
Reference in a new issue