aboutsummaryrefslogtreecommitdiff
path: root/extension/public/iconGrabber.js
diff options
context:
space:
mode:
Diffstat (limited to 'extension/public/iconGrabber.js')
-rw-r--r--extension/public/iconGrabber.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/extension/public/iconGrabber.js b/extension/public/iconGrabber.js
index a255d01..b02e315 100644
--- a/extension/public/iconGrabber.js
+++ b/extension/public/iconGrabber.js
@@ -1,9 +1,5 @@
function getBrowser() {
- if (typeof browser === "undefined") {
- return chrome;
- } else {
- return browser;
- }
+ return typeof browser === "undefined" ? chrome : browser;
}
const tagTypes = ["apple-touch-icon", "shortcut icon", "icon"]
@@ -12,11 +8,16 @@ let x = Array.from(document.getElementsByTagName("link"))
.filter(elem => tagTypes.includes(elem.rel))
.sort((a, b) => {
function compareTags() {
+ // ascending
return tagTypes.indexOf(a.rel) - tagTypes.indexOf(b.rel);
}
function compareSizes() {
- try { return Number(b.sizes[0].split('x')[0]) - Number(a.sizes[0].split('x')[0]); }
- catch { return -1; }
+ function getSize(elem) {
+ try { return Number(elem.sizes[0].split('x')[0]); }
+ catch { return 0; }
+ }
+ // descending
+ return getSize(b) - getSize(a);
}
return compareSizes() || compareTags()