|
1 |
| -import { net } from "electron"; |
| 1 | +import { net } from 'electron' |
2 | 2 |
|
3 |
| -export function fetchLatestBC(): Promise<BCVersion[]> { |
| 3 | +export function fallback (): BCVersion[] { |
| 4 | + // monthly advanced versions |
| 5 | + // 2025/05/16 ~ 2025/06/15 = R116 |
| 6 | + // 2025/06/16 ~ 2025/07/15 = R117 |
| 7 | + // 2025/07/16 ~ 2025/08/15 = R118 |
| 8 | + |
| 9 | + const dateTime = new Date() |
| 10 | + const year = dateTime.getUTCFullYear() |
| 11 | + const month = dateTime.getUTCMonth() |
| 12 | + const day = dateTime.getUTCDate() |
| 13 | + |
| 14 | + const vNumber = |
| 15 | + Math.floor((year - 2025) * 12 + month) + 111 + (day >= 16 ? 1 : 0) |
| 16 | + const version = `R${vNumber}` |
| 17 | + |
| 18 | + console.log(`Using fallback version: ${version}`) |
| 19 | + |
| 20 | + return [ |
| 21 | + { |
| 22 | + version, |
| 23 | + url: `https://www.bondageprojects.elementfx.com/${version}/BondageClub/`, |
| 24 | + }, |
| 25 | + { |
| 26 | + version, |
| 27 | + url: `https://www.bondage-europe.com/${version}/`, |
| 28 | + }, |
| 29 | + { |
| 30 | + version, |
| 31 | + url: `https://www.bondageprojects.elementfx.com/${version}/`, |
| 32 | + }, |
| 33 | + ] |
| 34 | +} |
| 35 | + |
| 36 | +export function fetchLatestBC (): Promise<BCVersion[]> { |
4 | 37 | return new Promise<BCVersion[]>((resolve, reject) => {
|
5 | 38 | net
|
6 |
| - .fetch("https://bondageprojects.com/club_game/", { |
| 39 | + .fetch('https://bondageprojects.com/club_game/', { |
7 | 40 | bypassCustomProtocolHandlers: true,
|
8 |
| - cache: "no-store", |
| 41 | + cache: 'no-store', |
9 | 42 | })
|
10 |
| - .then(async (response) => { |
| 43 | + .then(async response => { |
11 | 44 | if (!response.ok)
|
12 |
| - throw new Error(`HTTP ${response.status} ${response.statusText}`); |
| 45 | + throw new Error(`HTTP ${response.status} ${response.statusText}`) |
13 | 46 |
|
14 |
| - const html = await response.text(); |
| 47 | + const html = await response.text() |
15 | 48 |
|
16 | 49 | const matches = html.match(
|
17 | 50 | /onclick="window\.location='(https:\/\/www.bondage[^']+)'/g
|
18 |
| - ); |
| 51 | + ) |
19 | 52 |
|
20 | 53 | if (!matches || matches.length === 0) {
|
21 |
| - throw new Error("No valid bc versions found"); |
| 54 | + throw new Error('No valid bc versions found') |
22 | 55 | }
|
23 | 56 |
|
24 |
| - const versions: BCVersion[] = matches.map((match) => { |
25 |
| - const url = match.match(/'(https:\/\/www\.bondage[^']+)'/)?.[1]; |
26 |
| - const version = url?.match(/R\d+/)?.[0]; |
27 |
| - if (url && version) { |
28 |
| - return { url, version }; |
29 |
| - } |
30 |
| - return undefined; |
31 |
| - }).filter(Boolean) as BCVersion[]; |
32 |
| - resolve(versions); |
| 57 | + const versions: BCVersion[] = matches |
| 58 | + .map(match => { |
| 59 | + const url = match.match(/'(https:\/\/www\.bondage[^']+)'/)?.[1] |
| 60 | + const version = url?.match(/R\d+/)?.[0] |
| 61 | + if (url && version) { |
| 62 | + return { url, version } |
| 63 | + } |
| 64 | + return undefined |
| 65 | + }) |
| 66 | + .filter(Boolean) as BCVersion[] |
| 67 | + resolve(versions) |
33 | 68 | })
|
34 |
| - .catch(reject); |
35 |
| - }); |
| 69 | + .catch(reject) |
| 70 | + }) |
36 | 71 | }
|
0 commit comments