Skip to content

Instantly share code, notes, and snippets.

@chrmcg
Created August 9, 2023 02:31
Show Gist options
  • Save chrmcg/7d22638684f4d06f1fc9eead2fdadc18 to your computer and use it in GitHub Desktop.
Save chrmcg/7d22638684f4d06f1fc9eead2fdadc18 to your computer and use it in GitHub Desktop.
Linear status in favicon (Arc Boost)
/**
* This Boost updates the favicon in Linear tabs within Arc based on issue statuses.
* Install instructions:
* 1. Right-click on any Linear tab in Arc and click "Boost this site"
* 2. Click "Code", then in the "JS" tab, paste the following code
* 3. Edit the "statuses" array to match your own
*/
const updateIcon = () => {
// Remove existing favicons
const existingIcons = Array.from(document.getElementsByTagName('link'));
existingIcons.forEach(icon => {
if (icon.getAttribute('rel').includes('icon')) {
document.head.removeChild(icon);
}
});
const statuses = ['Backlog', 'Todo', 'In Progress', 'In Review', 'Done', 'Canceled'];
let svg = null;
let i = 0;
while (!svg && i < statuses.length) {
const els = document.querySelectorAll(`[aria-label="${statuses[i]}"]`);
els.forEach(el => {
if (el.tagName === 'svg' && el.parentElement.tagName === 'BUTTON') {
svg = el;
}
});
i++;
}
if (svg) {
const fill = svg.getAttribute('fill');
const href = `data:image/svg+xml,<svg
xmlns='http://www.w3.org/2000/svg'
viewBox='${svg.getAttribute('viewBox')}'
${fill ? `fill='${fill}'` : ''}
>
${svg.innerHTML}
</svg>`.replace(/#/g, '%23');
const link = document.createElement('link');
link.setAttribute('rel', 'icon');
link.setAttribute('href', href);
document.head.appendChild(link);
} else {
// Default Linear favicon
const link = document.createElement('link');
link.setAttribute('rel', 'icon');
link.setAttribute('sizes', 'any');
link.setAttribute('href', 'https://static.linear.app/client/assets/favicon-5f570855.ico');
document.head.appendChild(link);
}
};
// Wait for Linear to load, then update
setTimeout(updateIcon, 2 * 1000);
// Update again every five seconds
setInterval(updateIcon, 5 * 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment