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;
|
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) {
|
function update(ua) {
|
||||||
const browser = document.getElementById('browser').value;
|
const browser = document.getElementById('browser').value;
|
||||||
const os = document.getElementById('os').value;
|
const os = document.getElementById('os').value;
|
||||||
|
@ -43,7 +53,7 @@ function update(ua) {
|
||||||
tbody.textContent = '';
|
tbody.textContent = '';
|
||||||
|
|
||||||
parent.dataset.loading = true;
|
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 => {
|
.then(r => r.json()).catch(e => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
return [];
|
return [];
|
||||||
|
|
Loading…
Reference in a new issue