fixes #38
This commit is contained in:
parent
4106d2a4c5
commit
ecd5f1b7b7
3 changed files with 27 additions and 11 deletions
|
@ -15,7 +15,8 @@ var prefs = {
|
|||
mode: 'blacklist',
|
||||
color: '#ffa643',
|
||||
cache: true,
|
||||
exactMatch: false
|
||||
exactMatch: false,
|
||||
protected: ['google.com/recaptcha', 'gstatic.com/recaptcha']
|
||||
};
|
||||
chrome.storage.local.get(prefs, ps => {
|
||||
Object.assign(prefs, ps);
|
||||
|
@ -256,6 +257,9 @@ var onBeforeSendHeaders = ({tabId, url, requestHeaders, type}) => {
|
|||
if (cache[tabId] === true) {
|
||||
return;
|
||||
}
|
||||
if (prefs.protected.some(s => url.indexOf(s) !== -1)) {
|
||||
return {};
|
||||
}
|
||||
const str = (cache[tabId] || ua.object(tabId)).userAgent;
|
||||
if (str) {
|
||||
for (let i = 0, name = requestHeaders[0].name; i < requestHeaders.length; i += 1, name = requestHeaders[i].name) {
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
text-decoration: underline;
|
||||
text-decoration-style: dashed;
|
||||
}
|
||||
.spacer {
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
|
@ -24,7 +27,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><textarea id="blacklist" rows="3" placeholder="e.g.: www.google.com, www.bing.com"></textarea></td>
|
||||
<td class="spacer"><textarea id="blacklist" rows="3" placeholder="e.g.: www.google.com, www.bing.com"></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
@ -32,7 +35,7 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><textarea id="whitelist" rows="3" placeholder="e.g.: www.google.com, www.bing.com"></textarea></td>
|
||||
<td class="spacer"><textarea id="whitelist" rows="3" placeholder="e.g.: www.google.com, www.bing.com"></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
@ -40,16 +43,22 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><textarea id="custom" rows="5" wrap="off"></textarea></td>
|
||||
<td class="spacer"><textarea id="custom" rows="5" wrap="off"></textarea></td>
|
||||
</tr>
|
||||
<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>
|
||||
<td class="spacer"><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>
|
||||
<td class="spacer"><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>
|
||||
<td class="spacer"><label><input type="checkbox" id="faqs"> Open FAQs page on updates</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>A comma-separated list of keywords that the extension should not spoof the user-agent header. Use this list to protect URLs that contain these protected keywords. Each keyword need to be at least 5 char long.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><textarea id="protected" rows="3" wrap="off"></textarea></td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
|
|
|
@ -10,9 +10,9 @@ function notify(msg, period = 750) {
|
|||
|
||||
function prepare(str) {
|
||||
return str.split(/\s*,\s*/)
|
||||
.map(s => s.replace('http://', '')
|
||||
.map(s => s.replace('http://', '')
|
||||
.replace('https://', '').split('/')[0].trim())
|
||||
.filter((h, i, l) => h && l.indexOf(h) === i);
|
||||
.filter((h, i, l) => h && l.indexOf(h) === i);
|
||||
}
|
||||
|
||||
function save() {
|
||||
|
@ -35,7 +35,8 @@ function save() {
|
|||
blacklist: prepare(document.getElementById('blacklist').value),
|
||||
whitelist: prepare(document.getElementById('whitelist').value),
|
||||
custom,
|
||||
mode: document.querySelector('[name="mode"]:checked').value
|
||||
mode: document.querySelector('[name="mode"]:checked').value,
|
||||
protected: document.getElementById('protected').value.split(/\s*,\s*/).filter(s => s.length > 4)
|
||||
}, () => {
|
||||
restore();
|
||||
notify('Options saved.');
|
||||
|
@ -50,7 +51,8 @@ function restore() {
|
|||
mode: 'blacklist',
|
||||
whitelist: [],
|
||||
blacklist: [],
|
||||
custom: {}
|
||||
custom: {},
|
||||
protected: ['google.com/recaptcha', 'gstatic.com/recaptcha']
|
||||
}, prefs => {
|
||||
document.getElementById('exactMatch').checked = prefs.exactMatch;
|
||||
document.getElementById('faqs').checked = prefs.faqs;
|
||||
|
@ -59,6 +61,7 @@ function restore() {
|
|||
document.getElementById('blacklist').value = prefs.blacklist.join(', ');
|
||||
document.getElementById('whitelist').value = prefs.whitelist.join(', ');
|
||||
document.getElementById('custom').value = JSON.stringify(prefs.custom, null, 2);
|
||||
document.getElementById('protected').value = prefs.protected.join(', ');
|
||||
});
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', restore);
|
||||
|
|
Loading…
Reference in a new issue