/* avatar injection: find author links, prepend the user's avatar. repo-root prefix is derived from the author link itself so this works under any URL prefix (repolist, CGI, ...). */ (function(){ function repoRootFrom(href){ var m = href.match(/^(.*)\/(timeline|forumpost|info)([?\/]|$)/); return m ? m[1] : ""; } function injectInto(link){ var m = link.href.match(/[?&]u=([^&"]+)/); if( !m ) return; if( link.parentNode.querySelector("img.avatar") ) return; var img = document.createElement("img"); img.className = "avatar"; img.alt = ""; img.src = repoRootFrom(link.getAttribute("href")) + "/uv/avatars/" + m[1] + ".png"; img.onerror = function(){ img.remove(); }; link.parentNode.insertBefore(img, link); } function scan(){ var sel = ".forumPostHdr a[href*='u='], .timelineModernDetail a[href*='u='], .timelineColumnarDetail a[href*='u=']"; document.querySelectorAll(sel).forEach(injectInto); } if( document.readyState === "loading" ){ document.addEventListener("DOMContentLoaded", scan); }else{ scan(); } })();