Timeline: Go to post on image click

Here's JavaScript you may add to your injections which will go to the post when you click the header image in Timeline. By default, there's an onclick event that opens the image in a popup. This is a personal preference but I don't see the point in seeing an image, clicking it, and then seeing it again in a popup. I'd rather be taken to the full post.

If this helps you, consider donating: https://buymeacoffee.com/billyw

<script>
// In Timeline, go to post on image click
document.addEventListener("DOMContentLoaded", function() {
    function removeOnclickFromDynamicElements() {
        const anchorTags = document.querySelectorAll('.bx-tl-item-image a[onclick]');
        anchorTags.forEach(function(anchorTag) {
            anchorTag.removeAttribute('onclick');
        });
    }


    removeOnclickFromDynamicElements();


    const observer = new MutationObserver(function(mutations) {
        try {
            mutations.forEach(function(mutation) {
                if (mutation.addedNodes.length || mutation.removedNodes.length) {
                    removeOnclickFromDynamicElements();
                }
            });
        } catch (error) {
            console.error('MutationObserver error:', error);
        }
    });


    observer.observe(document.body, { childList: true, subtree: true });
});
</script>
  • 130
  • More
Replies (0)
Login or Join to comment.