optional parser
This commit is contained in:
parent
dd9c11948c
commit
df861e16ca
8 changed files with 653 additions and 108 deletions
|
@ -12,6 +12,7 @@
|
|||
.h {
|
||||
text-decoration: underline;
|
||||
text-decoration-style: dashed;
|
||||
font-weight: bold;
|
||||
}
|
||||
.spacer {
|
||||
padding-bottom: 10px;
|
||||
|
@ -45,6 +46,14 @@
|
|||
<tr>
|
||||
<td class="spacer"><textarea id="custom" rows="5" wrap="off"></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label><span class="h">Custom user-agent string parsing</span>: A JSON object to bypass the internal user-agent string parsing method. The keys are the actual user-agent strings and the value of each key is an object of the keys that need to be set for the "navigator" object. You can use the "[delete]" keyword if you want a key in the "navigator" object to get deleted.</label> Press <a href="#" id="sample-2">here</a> to insert a sample JSON object.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="spacer"><textarea id="parser" rows="5" wrap="off"></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<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>
|
||||
|
|
|
@ -28,6 +28,18 @@ function save() {
|
|||
}, 1000);
|
||||
}
|
||||
|
||||
let parser = {};
|
||||
const p = document.getElementById('parser').value;
|
||||
try {
|
||||
parser = JSON.parse(p);
|
||||
}
|
||||
catch (e) {
|
||||
window.setTimeout(() => {
|
||||
notify('Parser JSON error: ' + e.message, 5000);
|
||||
document.getElementById('parser').value = c;
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
chrome.storage.local.set({
|
||||
exactMatch: document.getElementById('exactMatch').checked,
|
||||
faqs: document.getElementById('faqs').checked,
|
||||
|
@ -35,6 +47,7 @@ function save() {
|
|||
blacklist: prepare(document.getElementById('blacklist').value),
|
||||
whitelist: prepare(document.getElementById('whitelist').value),
|
||||
custom,
|
||||
parser,
|
||||
mode: document.querySelector('[name="mode"]:checked').value,
|
||||
protected: document.getElementById('protected').value.split(/\s*,\s*/).filter(s => s.length > 4)
|
||||
}, () => {
|
||||
|
@ -55,6 +68,7 @@ function restore() {
|
|||
whitelist: [],
|
||||
blacklist: [],
|
||||
custom: {},
|
||||
parser: {},
|
||||
protected: ['google.com/recaptcha', 'gstatic.com/recaptcha']
|
||||
}, prefs => {
|
||||
document.getElementById('exactMatch').checked = prefs.exactMatch;
|
||||
|
@ -64,6 +78,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('parser').value = JSON.stringify(prefs.parser, null, 2);
|
||||
document.getElementById('protected').value = prefs.protected.join(', ');
|
||||
});
|
||||
}
|
||||
|
@ -81,6 +96,21 @@ document.getElementById('sample').addEventListener('click', e => {
|
|||
}, null, 2);
|
||||
});
|
||||
|
||||
document.getElementById('sample-2').addEventListener('click', e => {
|
||||
e.preventDefault();
|
||||
|
||||
document.getElementById('parser').value = JSON.stringify({
|
||||
'my-custom-useragent': {
|
||||
'appVersion': 'custom app version',
|
||||
'platform': 'custom platform',
|
||||
'vendor': '[delete]',
|
||||
'product': 'custom product',
|
||||
'oscpu': 'custom oscpu',
|
||||
'custom-variable': 'this is a custom variable'
|
||||
}
|
||||
}, null, 2);
|
||||
});
|
||||
|
||||
document.getElementById('donate').addEventListener('click', () => {
|
||||
chrome.tabs.create({
|
||||
url: chrome.runtime.getManifest().homepage_url + '?rd=donate'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue