Skip to content

Commit 1bec334

Browse files
committed
fix: Version selection page fails to load (Twitter, YouTube Music)
1 parent 44812fd commit 1bec334

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

public/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,8 @@ ws.onmessage = (msg) => {
695695
case 'appList': {
696696
let id = 0;
697697
for (const app of message.list) {
698-
const appName = app.appName.replace(' (Wear OS)', '');
699-
const link = app.link.replace('-wear-os', '');
698+
const appName = app.appName.replace(' (Wear OS)', '').replace(' (Android Automotive)', '');
699+
const link = app.link.replace('-wear-os', '').replace('-android-automotive', '');
700700
document.getElementById('appList').innerHTML += `
701701
<li>
702702
<input

utils/downloadApp.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,16 @@ async function downloadApp(ws) {
1313
const { version, arch } = global.apkInfo;
1414
const apkMirrorVersionArg = version.replace(/\./g, '-');
1515
const link = global.jarNames.selectedApp.link;
16+
const url = `https://www.apkmirror.com${link}${link.split('/')[3]}-${apkMirrorVersionArg}-release/`
1617

17-
let versionDownload = await fetchWithUserAgent(
18-
`https://www.apkmirror.com${link}${
19-
link.split('/')[3]
20-
}-${apkMirrorVersionArg}-release/`
21-
);
18+
let versionDownload = await fetchWithUserAgent(url);
19+
20+
if (
21+
!versionDownload.ok &&
22+
global.jarNames.selectedApp.packageName === 'com.twitter.android'
23+
) {
24+
versionDownload = await fetchWithUserAgent(url.replace('/twitter/twitter', '/twitter/x-previously-twitter'));
25+
}
2226

2327
if (!versionDownload.ok) {
2428
ws.send(

wsEvents/getAppVersion.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,27 @@ module.exports = async function getAppVersion(ws, message) {
196196
const regex = new RegExp(
197197
`(?<=${link}${link.split('/')[3]}-)(.*)(?=-release/)`
198198
);
199-
199+
const regexTwitter = new RegExp(
200+
`(?<=/apk/x-corp/twitter/x-previously-twitter-)(.*)(?=-release/)`
201+
);
200202
for (const version of $(
201203
'#primary h5.appRowTitle.wrapText.marginZero.block-on-mobile'
202204
).get()) {
203205
const versionTitle = version.attribs.title.toLowerCase();
204-
const versionName = version.children[0].next.attribs.href
205-
.match(regex)[0]
206-
.replace(/-/g, '.');
206+
const versionNameRaw = version.children[0].next.attribs.href;
207+
const versionNameMatch = versionNameRaw.match(regex);
208+
let versionName;
209+
if (global.jarNames.selectedApp.packageName === 'com.twitter.android' &&
210+
versionNameMatch === null
211+
) {
212+
versionName = versionNameRaw
213+
.match(regexTwitter)[0]
214+
.replace(/-/g, '.');
215+
} else {
216+
versionName = versionNameRaw
217+
.match(regex)[0]
218+
.replace(/-/g, '.');
219+
}
207220

208221
if (
209222
(global.jarNames.selectedApp.packageName === 'com.twitter.android' &&

0 commit comments

Comments
 (0)