-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
automatically replace link to file accordingly to selected version
- Loading branch information
1 parent
0fc307d
commit 59cb3e1
Showing
13 changed files
with
264 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
Copyright (C) 2024 Nintendo Homebrew | ||
SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
(() => { | ||
|
||
// probably not really needed? | ||
function c(key, value) { | ||
Object.defineProperty(window, key, { value, writable: false, enumerable: true, configurable: false }); | ||
} | ||
|
||
if (!window.COMMON_LOADED) { | ||
c("COMMON_LOADED", true); | ||
|
||
// Possible max minor for each major, major as key | ||
const major_minor_map = { | ||
0: -1, // invalidate all 0.x | ||
1: 1, | ||
2: 2, | ||
3: 1, | ||
4: 5, | ||
5: 1, | ||
6: 4, | ||
7: 2, | ||
8: 1, | ||
9: 9, | ||
10: 7, | ||
11: 17 | ||
} | ||
|
||
// Validate version | ||
// CHN/TWN doesn't have new model | ||
// KOR/CHN/TWN doesn't have 11.17 currently | ||
c("validate_version", (major, minor, native, region, model) => { | ||
if (model == DEVICE_N3DS && ["C", "T"].includes(region)) { | ||
return false; | ||
} | ||
|
||
if (major == 11 && minor == 17 && ["K", "C", "T"].includes(region)) { | ||
return false; | ||
} | ||
|
||
const minor_max = major_minor_map[major]; | ||
if (!isNaN(minor_max) && minor > minor_max) { | ||
return false; | ||
} | ||
|
||
return true; | ||
}); | ||
|
||
c("DEVICE_N3DS", 1); | ||
c("DEVICE_O3DS", 0); | ||
|
||
c("FILENAME_REGION_MAP", { | ||
"U": "usa", | ||
"E": "eur", | ||
"J": "jpn", | ||
"K": "kor", | ||
"C": "cnh", | ||
"T": "twn", | ||
}); | ||
} | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
Copyright (C) 2024 DannyAAM | ||
SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
(() => { | ||
|
||
const selectedVersion = sessionStorage.getItem("selected_version"); | ||
if (selectedVersion && window.MATCH && window.generateLink) { | ||
function replaceLink() { | ||
const {major, minor, nver, region, model} = JSON.parse(selectedVersion); | ||
if (!validate_version(major, minor, nver, region, model)) { | ||
return; | ||
} | ||
|
||
const links = document.querySelectorAll(`a[href*="${MATCH}"]`); | ||
for(const link of links) { | ||
const newLink = generateLink(major, minor, nver, region, model, link.href); | ||
if (newLink) { | ||
link.setAttribute("href", newLink); | ||
} | ||
} | ||
} | ||
|
||
if (document.readyState === "loading") { | ||
document.addEventListener("DOMContentLoaded", replaceLink); | ||
} else { | ||
replaceLink(); | ||
} | ||
} | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
Copyright (C) 2024 DannyAAM | ||
SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
(() => { | ||
|
||
const BASE = "https://hacksguidewiki.sfo3.digitaloceanspaces.com/hacksguidewiki/Super-skaterhax"; | ||
|
||
window.MATCH = "skater.nintendohomebrew.com"; | ||
|
||
window.generateLink = (major, minor, nver, region, model, link) => { | ||
const fileRegion = FILENAME_REGION_MAP[region]; | ||
|
||
if (model != DEVICE_N3DS || major < 11) { | ||
return null; | ||
} | ||
|
||
let fileVersion; | ||
switch (region) { | ||
case "U": | ||
if (minor == 17) { | ||
fileVersion = "v11.17"; | ||
} else { | ||
fileVersion = "pre17"; | ||
} | ||
break; | ||
case "K": | ||
if (minor == 17) { | ||
return null; | ||
} else { | ||
fileVersion = "pre17"; | ||
} | ||
break; | ||
default: | ||
fileVersion = "all"; | ||
break; | ||
} | ||
return `${BASE}-${fileRegion}-${fileVersion}.zip`; | ||
} | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
Copyright (C) 2024 DannyAAM | ||
SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
(() => { | ||
|
||
const BASE = "https://github.com/nedwill/soundhax/raw/master/soundhax"; | ||
|
||
window.MATCH = "soundhax.com"; | ||
|
||
window.generateLink = (major, minor, nver, region, model, link) => { | ||
const fileRegion = FILENAME_REGION_MAP[region]; | ||
|
||
if (model == DEVICE_N3DS) { | ||
return `${BASE}-${fileRegion}-n3ds.m4a`; | ||
} | ||
|
||
if (model == DEVICE_O3DS) { | ||
if (major <= 2 && ["K", "C", "T"].includes(region)) { | ||
return null; | ||
} | ||
|
||
let fileVersion; | ||
switch (parseInt(major)) { | ||
case 1: | ||
fileVersion = "pre2.1"; | ||
break; | ||
case 2: | ||
// 2.1 special case: | ||
// - if nver lower than 4, use pre 2.1, as sound app is not updated | ||
// - otherwise, use 2.1/2.2 for newer soundhax app | ||
if (minor == 1 && nver < 4) { | ||
fileVersion = "pre2.1"; | ||
} else { | ||
fileVersion = "v2.1and2.2"; | ||
} | ||
break; | ||
case 3: | ||
case 4: | ||
fileVersion = "v3.xand4.x"; | ||
break; | ||
default: // 5.x and later... maybe reject past 11.3? | ||
fileVersion = "post5.0"; | ||
break; | ||
} | ||
return `${BASE}-${fileRegion}-o3ds-${fileVersion}.m4a`; | ||
} | ||
|
||
return null; // wtf? | ||
} | ||
|
||
})(); |