version 0.4.1

This commit is contained in:
Ray Lothian 2020-09-06 13:26:09 +02:00
parent 855d93a46b
commit 1b18a4f7a2
6 changed files with 70 additions and 31 deletions

View file

@ -101,3 +101,9 @@ textarea {
grid-template-columns: 1fr 1fr;
}
}
.admin {
background-color: #ffffed;
border: solid 1px #e8ec3a;
padding: 10px;
margin: 15px 0;
}

View file

@ -60,12 +60,13 @@
<h1>Sibling Hostnames</h1>
<span id="toggle-sibling-desc">Description</span>
</div>
<p for="toggle-sibling-desc" class="note hidden">A JSON array that contains one or more groups of hostnames to have a single user-agent string per group for the "Custom Mode". For all hostnames in one group, the user-agent string calculation only occurs once, and all the other members use the same calculated string. This is useful to make sure a group of connected websites only access to the same user-agent string. Press <a href="#" id="sample-3">here</a> to insert a sample JSON array.</p>
<p for="toggle-sibling-desc" class="note hidden">A JSON array that contains one or more groups of hostnames to have a single user-agent string per group. For all hostnames in one group, the user-agent string calculation only occurs once, and all the other members use the same calculated string. This is useful to make sure a group of connected websites only access to the same user-agent string. Press <a href="#" id="sample-3">here</a> to insert a sample JSON array.</p>
<textarea id="siblings" rows="5" wrap="off"></textarea>
<div class="admin">This extension supports managed storage. All the preferences can be pre-configured by <a href="https://add0n.com/useragent-switcher.html#faq20">the domain administrator</a></div>
<div id="backup">
<button id="import">Import Settings</button>
<button id="export">Export Settings</button>
<button title="to generate minified version, press Shift key while pressing this button" id="export">Export Settings</button>
</div>
<div id="tools">
<button id="help">FAQs Page (Help)</button>

View file

@ -24,6 +24,7 @@ function save() {
catch (e) {
window.setTimeout(() => {
notify('Custom JSON error: ' + e.message, 5000);
alert('Custom JSON error: ' + e.message);
document.getElementById('custom').value = c;
}, 1000);
}
@ -36,6 +37,7 @@ function save() {
catch (e) {
window.setTimeout(() => {
notify('Parser JSON error: ' + e.message, 5000);
alert('Parser JSON error: ' + e.message);
document.getElementById('parser').value = p;
}, 1000);
}
@ -52,11 +54,10 @@ function save() {
catch (e) {
window.setTimeout(() => {
notify('Sibling JSON error: ' + e.message, 5000);
document.getElementById('siblings').value = c;
alert('Sibling JSON error: ' + e.message);
document.getElementById('siblings').value = s;
}, 1000);
}
console.log(siblings);
chrome.storage.local.set({
exactMatch: document.getElementById('exactMatch').checked,
@ -90,10 +91,7 @@ function restore() {
blacklist: [],
custom: {},
parser: {},
siblings: {
'www.google.com': 0,
'www.youtube.com': 0
},
siblings: {},
protected: ['google.com/recaptcha', 'gstatic.com/recaptcha']
}, prefs => {
document.getElementById('exactMatch').checked = prefs.exactMatch;
@ -178,9 +176,23 @@ document.getElementById('help').addEventListener('click', () => {
});
// export
document.getElementById('export').addEventListener('click', () => {
document.getElementById('export').addEventListener('click', e => {
const guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
const r = Math.random() * 16 | 0;
const v = c == 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
chrome.storage.local.get(null, prefs => {
const text = JSON.stringify(prefs, null, ' ');
for (const key of Object.keys(prefs)) {
if (key && key.startsWith('cache.')) {
delete prefs[key];
}
}
const text = JSON.stringify(Object.assign({}, prefs, {
'json-guid': guid,
'json-forced': false
}), null, e.shiftKey ? '' : ' ');
const blob = new Blob([text], {type: 'application/json'});
const objectURL = URL.createObjectURL(blob);
Object.assign(document.createElement('a'), {