Skip to content

Commit 3dc8454

Browse files
Deploy site from 504f27d
1 parent c00df38 commit 3dc8454

File tree

4 files changed

+89
-0
lines changed

4 files changed

+89
-0
lines changed

2025-01-18-v2025.118.151840/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,10 @@ <h4 class="card-title mb-3 fw-bolder">Donate</h4>
821821

822822

823823

824+
825+
<script src="/assets/js/changelog-links.js"></script>
826+
827+
824828

825829

826830
</body>

2025-01-22-v2025.122.141614/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,10 @@ <h4 class="card-title mb-3 fw-bolder">Donate</h4>
716716

717717

718718

719+
720+
<script src="/assets/js/changelog-links.js"></script>
721+
722+
719723

720724

721725
</body>

2025-06-28-v2025.628.4510/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,10 @@ <h4 class="card-title mb-3 fw-bolder">Donate</h4>
778778

779779

780780

781+
782+
<script src="/assets/js/changelog-links.js"></script>
783+
784+
781785

782786

783787
</body>

assets/js/changelog-links.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* Convert Full Changelog URLs to clickable links in GitHub release notes
3+
*/
4+
(function() {
5+
'use strict';
6+
7+
function makeChangelogLinksClickable() {
8+
// Find all paragraphs that contain "Full Changelog" text and a GitHub compare URL
9+
const paragraphs = document.querySelectorAll('p');
10+
11+
// Loop through paragraphs in reverse order and break after the first match
12+
for (let i = paragraphs.length - 1; i >= 0; i--) {
13+
const paragraph = paragraphs[i];
14+
const text = paragraph.textContent || paragraph.innerText;
15+
16+
// Check if this paragraph contains "Full Changelog" and a GitHub compare URL
17+
if (
18+
text.includes('Full Changelog') &&
19+
text.includes('/compare/') &&
20+
text.includes('…')
21+
) {
22+
// Extract the URL from the text
23+
const urlMatch = text.match(/(https:\/\/github\.com\/\S+)/);
24+
25+
if (!urlMatch) {
26+
continue;
27+
}
28+
29+
const url = urlMatch[1];
30+
let parsedUrl;
31+
try {
32+
parsedUrl = new URL(url);
33+
} catch (e) {
34+
continue;
35+
}
36+
// Only allow https://github.com links with the expected pathname format
37+
// Pattern: /LizardByte/<repo-name>/compare/<version-a>…<version-b>
38+
const encodedEllipsis = encodeURI('…')
39+
const githubOrg = 'LizardByte'
40+
const pathPattern = new RegExp(`^\\/${githubOrg}\\/\\S+\\/compare\\/\\S+${encodedEllipsis}\\S+$`);
41+
if (
42+
parsedUrl.protocol !== 'https:' ||
43+
parsedUrl.hostname !== 'github.com' ||
44+
!pathPattern.test(parsedUrl.pathname)
45+
) {
46+
continue;
47+
}
48+
49+
// Safely replace the URL text in the paragraph with a clickable link
50+
const urlIndex = text.indexOf(url);
51+
// Clear the paragraph contents
52+
paragraph.textContent = '';
53+
// Add text before the URL as a text node
54+
paragraph.appendChild(document.createTextNode(text.slice(0, urlIndex)));
55+
// Create the anchor element for the URL
56+
const link = document.createElement('a');
57+
link.href = parsedUrl.href;
58+
link.textContent = decodeURI(parsedUrl.href);
59+
link.target = '_blank';
60+
link.rel = 'noopener noreferrer';
61+
paragraph.appendChild(link);
62+
// Add text after the URL as a text node
63+
paragraph.appendChild(document.createTextNode(text.slice(urlIndex + url.length)));
64+
65+
// Break after first match
66+
break;
67+
}
68+
}
69+
}
70+
71+
// Run when DOM is ready
72+
if (document.readyState === 'loading') {
73+
document.addEventListener('DOMContentLoaded', makeChangelogLinksClickable);
74+
} else {
75+
makeChangelogLinksClickable();
76+
}
77+
})();

0 commit comments

Comments
 (0)