Hi,
I've made some custom styling to the file links shared in posts. Instead of looking like simple links, with a help of JS code, I've made them to look like this:

In my case, the custom JS function looks through all the file links on the page and applies custom CSS to all found <a> tags.
But there are a few problems with this approach
When you enter a topic somewhere below (at a post in the bottom of the topic) and then scroll up, the JS function doesn't work, because it was called only once on page load. I assume this happens because of the dynamic posts load.
Is there a way to trigger JS function on page scroll or on the dynamic load events?
Test page: https://forum.c4d.space/topic/74/морф/18?_=1609934812169
Here is the JS function itself:
new PretifyFileLinks();
function PretifyFileLinks() {
const extensionPattern = /\.[0-9a-z]+$/i;
const extensions = ['.c4d', '.zip', '.7z'];
const allLinks = document.querySelectorAll('[component="post"] a');
allLinks.forEach(link => {
const ext = link.href.match(extensionPattern);
if (ext === null) return;
extensions.forEach(extension => {
if (extension === ext[0]) beautifyLink(link);
});
});
function beautifyLink(obj) {
const css = `Some custom CSS.`;
obj.style.cssText = css;
}
}