Skip to content

Commit 5218ca4

Browse files
committed
fix: changelog from github
1 parent 452f48c commit 5218ca4

File tree

2 files changed

+15
-23
lines changed

2 files changed

+15
-23
lines changed

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# UnderScript Changelog
22

3-
## Version 0.63.12 (2026-01-06)
3+
## Version 0.63.13 (2026-01-06)
44
Apparently UnderScript updates were broken and the past 2 releases didn't go through. Here's the changes:
55
1. Fixed filters not resetting to first page
66
1. Fixed battle log not translating story username

src/base/underscript/changelog.js

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import luxon from 'luxon';
12
import showdown from 'showdown';
23
import axios from 'axios';
34
import { scriptVersion } from 'src/utils/1.variables.js';
@@ -39,13 +40,6 @@ function getMarkdown() {
3940
}
4041
return changelog.markdown;
4142
}
42-
function getAxios() {
43-
if (!changelog.axios) {
44-
// TODO: get from github?
45-
changelog.axios = axios.create({ baseURL: 'https://unpkg.com/' });
46-
}
47-
return changelog.axios;
48-
}
4943

5044
function open(message) {
5145
BootstrapDialog.show({
@@ -61,25 +55,23 @@ function open(message) {
6155
});
6256
}
6357

64-
export function get(version = 'latest', short = false) {
58+
export async function get(version = 'latest', short = false) {
6559
const cache = version.includes('.');
6660
const key = `${version}${short ? '_short' : ''}`;
6761
if (cache && changelog[key]) return Promise.resolve(changelog[key]);
6862

69-
const extension = `underscript@${version}/changelog.md`;
70-
return getAxios().get(extension).then(({ data: text }) => {
71-
const first = text.indexOf(`\n## ${cache ? `Version ${version}` : ''}`);
72-
let end;
73-
if (!~first) throw new Error('Invalid Changelog');
74-
if (short) {
75-
const index = text.indexOf('\n## ', first + 1);
76-
if (index !== -1) end = index;
77-
}
78-
const parsedHTML = getMarkdown().makeHtml(text.substring(first, end).trim()).replace(/\r?\n/g, '');
79-
// Cache results
80-
if (cache) changelog[key] = parsedHTML;
81-
return parsedHTML;
82-
});
63+
if (version === 'latest') {
64+
const { data } = await axios.get('https://raw.githubusercontent.com/UCProjects/UnderScript/refs/heads/master/changelog.md');
65+
66+
return getMarkdown().makeHtml(data.substring(data.indexOf('##'))).replace(/\r?\n/g, '');
67+
}
68+
69+
const { data: { body: text, name, published_at: published } } = await axios.get(`https://api.github.com/repos/UCProjects/UnderScript/releases/tags/${version}}`);
70+
const date = luxon.DateTime.fromISO(published).toLocaleString(luxon.DateTime.DATE_MED);
71+
const parsedHTML = getMarkdown().makeHtml(`## ${name} (${date})\n${text}`).replace(/\r?\n/g, '');
72+
// Cache results
73+
if (cache) changelog[key] = parsedHTML;
74+
return parsedHTML;
8375
}
8476

8577
export function load(version = 'latest', short = false) {

0 commit comments

Comments
 (0)