allow the admin to alter the default user-agent string

This commit is contained in:
Ray Lothian 2020-08-04 10:22:18 +02:00
parent 4e4ccd589c
commit d0340982fc
4 changed files with 32 additions and 9 deletions

View file

@ -156,7 +156,6 @@ document.addEventListener('DOMContentLoaded', () => fetch('./map.json').then(r =
document.querySelector('#os optgroup:last-of-type').appendChild(f2);
chrome.storage.local.get({
'ua': '',
'popup-browser': 'Chrome',
'popup-os': 'Windows',
'popup-sort': 'descending'
@ -165,10 +164,12 @@ document.addEventListener('DOMContentLoaded', () => fetch('./map.json').then(r =
document.getElementById('os').value = prefs['popup-os'];
document.getElementById('sort').value = prefs['popup-sort'];
const ua = prefs.ua || navigator.userAgent;
update(ua);
document.getElementById('ua').value = ua;
document.getElementById('ua').dispatchEvent(new Event('input'));
chrome.runtime.getBackgroundPage(bg => {
const ua = bg.prefs.ua || navigator.userAgent;
update(ua);
document.getElementById('ua').value = ua;
document.getElementById('ua').dispatchEvent(new Event('input'));
});
});
}));