update ua's from repo
This commit is contained in:
parent
80823ddf65
commit
492fefb170
1 changed files with 11 additions and 1 deletions
|
@ -33,6 +33,16 @@ function sort(arr) {
|
|||
return list;
|
||||
}
|
||||
|
||||
function get(path) {
|
||||
return caches.open('agents').then(cache => {
|
||||
const link = 'https://cdn.jsdelivr.net/gh/ray-lothian/UserAgent-Switcher/node/' + path;
|
||||
cache.add(link);
|
||||
return cache.match(link).then(resp => {
|
||||
return resp || fetch(path);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function update(ua) {
|
||||
const browser = document.getElementById('browser').value;
|
||||
const os = document.getElementById('os').value;
|
||||
|
@ -43,7 +53,7 @@ function update(ua) {
|
|||
tbody.textContent = '';
|
||||
|
||||
parent.dataset.loading = true;
|
||||
fetch('browsers/' + browser.toLowerCase() + '-' + os.toLowerCase().replace(/\//g, '-') + '.json')
|
||||
get('browsers/' + browser.toLowerCase() + '-' + os.toLowerCase().replace(/\//g, '-') + '.json')
|
||||
.then(r => r.json()).catch(e => {
|
||||
console.error(e);
|
||||
return [];
|
||||
|
|
Loading…
Reference in a new issue