summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--head.html15
1 files changed, 15 insertions, 0 deletions
diff --git a/head.html b/head.html
index 96f3daf..68bda81 100644
--- a/head.html
+++ b/head.html
@@ -15,5 +15,20 @@ document.addEventListener('DOMContentLoaded', function() {
node.textContent = node.textContent.replace(' : ', '/');
}
});
+
+ // Rewrite relative img src in README/about pages to cgit plain/ endpoint
+ if (/\/about\//.test(window.location.pathname)) {
+ var m = window.location.pathname.match(/^\/([^/]+)\/about\//);
+ if (m) {
+ var repo = m[1];
+ var branch = (new URLSearchParams(window.location.search)).get('h') || 'main';
+ document.querySelectorAll('div#summary img').forEach(function(img) {
+ var src = img.getAttribute('src');
+ if (src && !/^https?:\/\//.test(src) && !/^\//.test(src)) {
+ img.src = '/' + repo + '/plain/' + src + '?h=' + branch;
+ }
+ });
+ }
+ }
});
</script>