Skip to content

Commit

Permalink
fixes #37
Browse files Browse the repository at this point in the history
  • Loading branch information
ray-lothian committed Mar 14, 2019
1 parent 31c1261 commit aa31d04
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion extension/data/popup/index.html
Expand Up @@ -19,7 +19,7 @@
<th colspan="3">
<select id="browser">
<optgroup label="Populars">
<option value="Internet Explorer">Internet Explorer</option>
<option value="IE">Internet Explorer</option>
<option value="Safari">Safari</option>
<option value="Chrome">Chrome</option>
<option value="Firefox">Firefox</option>
Expand Down
5 changes: 4 additions & 1 deletion extension/data/popup/index.js
Expand Up @@ -43,7 +43,10 @@ function update() {
tbody.textContent = '';

parent.dataset.loading = true;
fetch('browsers/' + browser + '-' + os.replace(/\//g, '-') + '.json').then(r => r.json()).catch(() => []).then(list => {
fetch('browsers/' + browser + '-' + os.replace(/\//g, '-') + '.json').then(r => r.json()).catch(e => {
console.error(e);
return [];
}).then(list => {
if (list) {
const fragment = document.createDocumentFragment();
for (const o of sort(list)) {
Expand Down
2 changes: 1 addition & 1 deletion node/browsers/IE-Windows.json

Large diffs are not rendered by default.

37 changes: 34 additions & 3 deletions node/build.js
Expand Up @@ -9,7 +9,15 @@ var map = {};

var parser = new UAParser();

fs.readdir('./browsers/', (err, files) => {
var write = ({name, content}, callback) => fs.writeFile('./browsers/' + name, content, 'utf8', e => {
if (e) {
console.log(e);
}
setTimeout(callback, 0);
console.log(name);
});

fs.readdir('./browsers/', async (err, files) => {
if (err) throw err;
for (const file of files) {
fs.unlinkSync(path.join('./browsers/', file), err => {
Expand All @@ -25,17 +33,40 @@ fs.readdir('./browsers/', (err, files) => {
parser.setUA(ua);
const o = parser.getResult();
if (o.browser.name && o.os.name) {
if (o.os.name === 'WIndows') {
continue;
}
cache[o.browser.name] = cache[o.browser.name] || {};
map[o.browser.name] = map[o.browser.name] || {};
cache[o.browser.name][o.os.name] = cache[o.browser.name][o.os.name] || [];
map[o.browser.name][o.os.name] = map[o.browser.name][o.os.name] || true;
cache[o.browser.name][o.os.name].push(o);
}
else {
// console.log(ua);
}
}
const contents = [];
for (const browser of Object.keys(cache)) {
for (const os of Object.keys(cache[browser])) {
fs.writeFileSync('./browsers/' + browser + '-' + os.replace(/\//g, '-') + '.json', JSON.stringify(cache[browser][os]));
const name = browser + '-' + os.replace(/\//g, '-') + '.json';
const content = JSON.stringify(cache[browser][os]);
contents.push({
name,
content
});
}
}
fs.writeFile('./map.json', JSON.stringify(map), () => {});
const once = () => {
const obj = contents.shift();
if (obj) {
write(obj, once);
}
else {
console.log('done');
fs.writeFile('./map.json', JSON.stringify(map), () => {});
}
};
once();
});

2 changes: 1 addition & 1 deletion node/map.json
@@ -1 +1 @@
{"Opera":{"Mac OS":true,"Windows":true,"Android":true,"Symbian":true,"Linux":true,"Ubuntu":true,"Debian":true,"Mint":true,"FreeBSD":true,"Nintendo":true,"OpenSolaris":true,"Solaris":true,"OpenBSD":true,"kubuntu":true,"UNIX":true},"Firefox":{"Mac OS":true,"Windows":true,"Android":true,"iOS":true,"Ubuntu":true,"Linux":true,"Fedora":true,"OpenBSD":true,"NetBSD":true,"Mageia":true,"FreeBSD":true,"Gentoo":true,"SUSE":true,"CentOS":true,"Slackware":true,"Mint":true,"DragonFly":true,"Solaris":true,"Kubuntu":true,"Mandriva":true,"BeOS":true,"Debian":true},"Chrome":{"Mac OS":true,"Windows":true,"Android":true,"Linux":true,"OpenBSD":true,"Chromium OS":true,"NetBSD":true,"FreeBSD":true,"Slackware":true,"SUSE":true,"Ubuntu":true,"Debian":true,"iOS":true,"Fedora":true},"IE":{"Windows":true,"Mac OS":true,"WIndows":true,"Solaris":true,"Linux":true,"Unix":true},"Mobile Safari":{"iOS":true,"BlackBerry":true,"Windows":true},"IEMobile":{"Windows Phone":true,"Windows Phone OS":true,"Windows":true},"Safari":{"Mac OS":true,"Android":true,"Symbian":true,"Windows":true,"Linux":true},"Android Browser":{"Android":true,"Windows":true},"Opera Mobi":{"Android":true,"Symbian":true,"Windows":true,"Mac OS":true,"Linux":true},"Opera Mini":{"iOS":true,"Symbian":true,"BlackBerry":true,"Android":true,"Windows":true,"Mac OS":true,"Linux":true,"UNIX":true},"UCBrowser":{"Android":true,"Windows":true},"Puffin":{"Android":true},"Samsung Browser":{"Android":true},"Yandex":{"Android":true,"Windows":true},"MIUI Browser":{"Android":true},"Edge":{"Windows Phone":true,"Windows":true},"WebKit":{"BlackBerry":true,"Symbian":true,"Mac OS":true,"Windows":true,"Linux":true},"Blazer":{"Windows":true},"BOLT":{"Windows":true},"Webkit":{"Symbian":true,"Linux":true},"Fennec":{"Android":true,"Windows":true,"Linux":true,"Mac OS":true},"GoBrowser":{"Android":true},"Maemo Browser":{"Linux":true},"Minimo":{"Linux":true,"Windows":true,"OpenBSD":true},"Kindle":{"Linux":true},"Opera Mi":{"Windows":true},"Skyfire":{"Mac OS":true},"Chromium":{"Ubuntu":true,"Linux":true},"Avant ":{"Windows":true},"Maxthon":{"Windows":true},"Arora":{"Linux":true,"Windows":true},"Mozilla":{"Windows":true,"Debian":true,"Linux":true,"Ubuntu":true,"Mac OS":true,"OpenBSD":true,"BeOS":true,"Haiku":true,"Solaris":true,"SUSE":true,"Fedora":true,"Gentoo":true,"Slackware":true,"Mint":true,"Mandriva":true,"Kubuntu":true,"CentOS":true,"FreeBSD":true,"Zenwalk":true,"ubuntu":true,"OS/2":true,"AIX":true,"QNX":true,"NetBSD":true,"Android":true},"Epiphany":{"Linux":true,"Ubuntu":true,"OpenBSD":true,"FreeBSD":true,"SUSE":true,"Fedora":true,"Debian":true,"Gentoo":true,"Solaris":true},"Camino":{"Mac OS":true},"Chimera":{"Mac OS":true},"Comodo Dragon":{"Windows":true,"Linux":true},"conkeror":{"Debian":true,"Windows":true,"Linux":true},"Conkeror":{"Debian":true},"Links":{"Linux":true,"NetBSD":true,"gentoo":true,"Unix":true,"OpenBSD":true,"FreeBSD":true,"Mac OS":true,"Solaris":true,"Debian":true},"links":{"Linux":true},"Firebird":{"Windows":true,"Mac OS":true,"Solaris":true,"Linux":true},"firefox":{"Linux":true},"Swiftfox":{"Linux":true},"Netscape":{"Windows":true,"Mac OS":true,"Linux":true,"Solaris":true,"AIX":true},"Flock":{"Mac OS":true,"Windows":true,"Linux":true},"iCab":{"Mac OS":true,"Windows":true},"Iceape":{"Linux":true},"icecat":{"Linux":true},"IceCat":{"Linux":true},"Iceweasel":{"Linux":true,"Debian":true,"debian":true,"Gentoo":true,"Ubuntu":true},"IceWeasel":{"Ubuntu":true,"Debian":true,"Windows":true},"iceweasel":{"Debian":true},"Iron":{"Windows":true,"Linux":true,"Mac OS":true},"K-Meleon":{"Windows":true,"Linux":true,"FreeBSD":true},"Konqueror":{"Linux":true,"FreeBSD":true,"Fedora":true,"Kubuntu":true,"Slackware":true,"OpenBSD":true,"DragonFly":true,"Windows":true,"Solaris":true,"NetBSD":true,"SUSE":true,"Debian":true},"Lunascape":{"Windows":true},"Lynx":{"GNU":true},"MAXTHON":{"Windows":true},"midori":{"Linux":true},"Midori":{"Linux":true,"FreeBSD":true,"Windows":true},"KHTML":{"Windows":true},"Mosaic":{"Windows":true,"AIX":true,"Solaris":true},"NetSurf":{"RISC OS":true,"Linux":true,"NetBSD":true},"OmniWeb":{"Mac OS":true},"Opera Tablet":{"Windows":true,"Symbian":true},"PaleMoon":{"Windows":true},"Palemoon":{"Windows":true},"Phoenix":{"Linux":true,"Windows":true,"Mac OS":true},"RockMelt":{"Windows":true,"Mac OS":true},"SeaMonkey":{"Windows":true,"Linux":true,"OS/2":true,"Mac OS":true,"FreeBSD":true,"OpenBSD":true,"Fedora":true,"SUSE":true,"Mandriva":true,"Gentoo":true,"BeOS":true,"Haiku":true,"AmigaOS":true,"CentOS":true},"Seamonkey":{"Windows":true,"Linux":true},"Slim":{"Windows":true},"w3m":{"Debian":true},"IceDragon":{"Windows":true},"Waterfox":{"Windows":true,"Linux":true},"GSA":{"iOS":true},"Vivaldi":{"Windows":true,"Linux":true},"Facebook":{"iOS":true,"Android":true},"Chrome WebView":{"Android":true},"QQBrowser":{"Windows":true},"Iridium":{"Windows":true}}
{"Opera":{"Mac OS":true,"Windows":true,"Android":true,"Symbian":true,"Linux":true,"Ubuntu":true,"Debian":true,"Mint":true,"FreeBSD":true,"Nintendo":true,"OpenSolaris":true,"Solaris":true,"OpenBSD":true,"kubuntu":true,"UNIX":true},"Firefox":{"Mac OS":true,"Windows":true,"Android":true,"iOS":true,"Ubuntu":true,"Linux":true,"Fedora":true,"OpenBSD":true,"NetBSD":true,"Mageia":true,"FreeBSD":true,"Gentoo":true,"SUSE":true,"CentOS":true,"Slackware":true,"Mint":true,"DragonFly":true,"Solaris":true,"Kubuntu":true,"Mandriva":true,"BeOS":true,"Debian":true},"Chrome":{"Mac OS":true,"Windows":true,"Android":true,"Linux":true,"OpenBSD":true,"Chromium OS":true,"NetBSD":true,"FreeBSD":true,"Slackware":true,"SUSE":true,"Ubuntu":true,"Debian":true,"iOS":true,"Fedora":true},"IE":{"Windows":true,"Mac OS":true,"Solaris":true,"Linux":true,"Unix":true},"Mobile Safari":{"iOS":true,"BlackBerry":true,"Windows":true},"IEMobile":{"Windows Phone":true,"Windows Phone OS":true,"Windows":true},"Safari":{"Mac OS":true,"Android":true,"Symbian":true,"Windows":true,"Linux":true},"Android Browser":{"Android":true,"Windows":true},"Opera Mobi":{"Android":true,"Symbian":true,"Windows":true,"Mac OS":true,"Linux":true},"Opera Mini":{"iOS":true,"Symbian":true,"BlackBerry":true,"Android":true,"Windows":true,"Mac OS":true,"Linux":true,"UNIX":true},"UCBrowser":{"Android":true,"Windows":true},"Puffin":{"Android":true},"Samsung Browser":{"Android":true},"Yandex":{"Android":true,"Windows":true},"MIUI Browser":{"Android":true},"Edge":{"Windows Phone":true,"Windows":true},"WebKit":{"BlackBerry":true,"Symbian":true,"Mac OS":true,"Windows":true,"Linux":true},"Blazer":{"Windows":true},"BOLT":{"Windows":true},"Webkit":{"Symbian":true,"Linux":true},"Fennec":{"Android":true,"Windows":true,"Linux":true,"Mac OS":true},"GoBrowser":{"Android":true},"Maemo Browser":{"Linux":true},"Minimo":{"Linux":true,"Windows":true,"OpenBSD":true},"Kindle":{"Linux":true},"Opera Mi":{"Windows":true},"Skyfire":{"Mac OS":true},"Chromium":{"Ubuntu":true,"Linux":true},"Avant ":{"Windows":true},"Maxthon":{"Windows":true},"Arora":{"Linux":true,"Windows":true},"Mozilla":{"Windows":true,"Debian":true,"Linux":true,"Ubuntu":true,"Mac OS":true,"OpenBSD":true,"BeOS":true,"Haiku":true,"Solaris":true,"SUSE":true,"Fedora":true,"Gentoo":true,"Slackware":true,"Mint":true,"Mandriva":true,"Kubuntu":true,"CentOS":true,"FreeBSD":true,"Zenwalk":true,"ubuntu":true,"OS/2":true,"AIX":true,"QNX":true,"NetBSD":true,"Android":true},"Epiphany":{"Linux":true,"Ubuntu":true,"OpenBSD":true,"FreeBSD":true,"SUSE":true,"Fedora":true,"Debian":true,"Gentoo":true,"Solaris":true},"Camino":{"Mac OS":true},"Chimera":{"Mac OS":true},"Comodo Dragon":{"Windows":true,"Linux":true},"conkeror":{"Debian":true,"Windows":true,"Linux":true},"Conkeror":{"Debian":true},"Links":{"Linux":true,"NetBSD":true,"gentoo":true,"Unix":true,"OpenBSD":true,"FreeBSD":true,"Mac OS":true,"Solaris":true,"Debian":true},"links":{"Linux":true},"Firebird":{"Windows":true,"Mac OS":true,"Solaris":true,"Linux":true},"firefox":{"Linux":true},"Swiftfox":{"Linux":true},"Netscape":{"Windows":true,"Mac OS":true,"Linux":true,"Solaris":true,"AIX":true},"Flock":{"Mac OS":true,"Windows":true,"Linux":true},"iCab":{"Mac OS":true,"Windows":true},"Iceape":{"Linux":true},"icecat":{"Linux":true},"IceCat":{"Linux":true},"Iceweasel":{"Linux":true,"Debian":true,"debian":true,"Gentoo":true,"Ubuntu":true},"IceWeasel":{"Ubuntu":true,"Debian":true,"Windows":true},"iceweasel":{"Debian":true},"Iron":{"Windows":true,"Linux":true,"Mac OS":true},"K-Meleon":{"Windows":true,"Linux":true,"FreeBSD":true},"Konqueror":{"Linux":true,"FreeBSD":true,"Fedora":true,"Kubuntu":true,"Slackware":true,"OpenBSD":true,"DragonFly":true,"Windows":true,"Solaris":true,"NetBSD":true,"SUSE":true,"Debian":true},"Lunascape":{"Windows":true},"Lynx":{"GNU":true},"MAXTHON":{"Windows":true},"midori":{"Linux":true},"Midori":{"Linux":true,"FreeBSD":true,"Windows":true},"KHTML":{"Windows":true},"Mosaic":{"Windows":true,"AIX":true,"Solaris":true},"NetSurf":{"RISC OS":true,"Linux":true,"NetBSD":true},"OmniWeb":{"Mac OS":true},"Opera Tablet":{"Windows":true,"Symbian":true},"PaleMoon":{"Windows":true},"Palemoon":{"Windows":true},"Phoenix":{"Linux":true,"Windows":true,"Mac OS":true},"RockMelt":{"Windows":true,"Mac OS":true},"SeaMonkey":{"Windows":true,"Linux":true,"OS/2":true,"Mac OS":true,"FreeBSD":true,"OpenBSD":true,"Fedora":true,"SUSE":true,"Mandriva":true,"Gentoo":true,"BeOS":true,"Haiku":true,"AmigaOS":true,"CentOS":true},"Seamonkey":{"Windows":true,"Linux":true},"Slim":{"Windows":true},"w3m":{"Debian":true},"IceDragon":{"Windows":true},"Waterfox":{"Windows":true,"Linux":true},"GSA":{"iOS":true},"Vivaldi":{"Windows":true,"Linux":true},"Facebook":{"iOS":true,"Android":true},"Chrome WebView":{"Android":true},"QQBrowser":{"Windows":true},"Iridium":{"Windows":true}}

0 comments on commit aa31d04

Please sign in to comment.