Last active
July 16, 2022 17:56
-
-
Save ottsch/51a3640910a82d36fcd1fc70ad4b109b to your computer and use it in GitHub Desktop.
Add favicon to links in Roam Research
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new MutationObserver(() => { | |
let filtered = Array.prototype.filter.call( | |
document.querySelectorAll(".roam-body a"), | |
(a) => { | |
return a.hostname && !a.hostname.includes("roamresearch.com"); | |
} | |
); | |
Array.prototype.forEach.call(filtered, (a) => { | |
if (a.text == "*") { | |
a.style.background = `url(https://www.google.com/s2/favicons?sz=16&domain=${a.hostname}) right center no-repeat`; | |
a.style.paddingRight = "18px"; | |
} else { | |
a.style.background = `url(https://www.google.com/s2/favicons?sz=16&domain=${a.hostname}) left center no-repeat`; | |
a.style.paddingLeft = "20px"; | |
} | |
}); | |
}).observe(document.body, { | |
attributes: true, | |
childList: true, | |
subtree: true, | |
}); |
@8bitgentleman of course, go ahead!
Full disclosure @ottsch there is the potential for some proceeds from Roam for those who update and maintain plugins on the marketplace. Want to make sure you're aware of that and still OK with passing it on
@8bitgentleman Yep, that's fine with me
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@ottsch any interest in updating this for the new official Roam plugin marketplace? If not would you be comfortable passing the reins to me or someone in the Roam community to keep it updated?