diff options
Diffstat (limited to 'extension/public/iconGrabber.js')
-rw-r--r-- | extension/public/iconGrabber.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/extension/public/iconGrabber.js b/extension/public/iconGrabber.js new file mode 100644 index 0000000..63ba7e0 --- /dev/null +++ b/extension/public/iconGrabber.js @@ -0,0 +1,15 @@ +const tagTypes = ["apple-touch-icon", "shortcut icon", "icon"] + +let x = Array.from(document.getElementsByTagName("link")) + .filter(elem => tagTypes.includes(elem.rel)) + .sort((a, b) => { + let tagCompare = tagTypes.indexOf(a.rel) - tagTypes.indexOf(b.rel); + if (tagCompare !== 0) return tagCompare; + try { return Number(b.sizes[0].split('x')[0]) - Number(a.sizes[0].split('x')[0]); } + catch { return -1; } + }) + .map(elem => elem.href); + +chrome.runtime.sendMessage([window.location.href, x[0]]).catch(() => { + console.log("failed to send message") +})
\ No newline at end of file |