diff --git a/docs/public/scripts/ssnc.js b/docs/public/scripts/ssnc.js
index 2369aa3..93310c7 100644
--- a/docs/public/scripts/ssnc.js
+++ b/docs/public/scripts/ssnc.js
@@ -1,111 +1,121 @@
-const prefix = document.getElementById("serial-prefix");
-const digits = document.getElementById("serial-digits");
-const result = document.getElementById("serial-result");
-const resultSerial = document.getElementById("serial-result-serial");
-const resultText = document.getElementById("serial-result-text");
+function initSerialChecker() {
+ const prefix = document.getElementById("serial-prefix");
+ const digits = document.getElementById("serial-digits");
+ const result = document.getElementById("serial-result");
+ const resultSerial = document.getElementById("serial-result-serial");
+ const resultText = document.getElementById("serial-result-text");
-function checkSerial(s) {
- if (s.match(/^X[KJWT][JWCE]/)) return 'mariko';
- if (s.match(/^HA[JKWE]/)) return 'switch2';
- if (!s.match(/^XA[JKW9][1479]/)) return 'invalid';
+ if (!prefix || !digits) return;
- if (s.length >= 10 && s.length < 14) s = s.padEnd(14, 'X');
- if (s.length !== 14) return 'invalid';
+ function checkSerial(s) {
+ if (s.match(/^X[KJWT][JWCE]/)) return 'mariko';
+ if (s.match(/^HA[JKWE]/)) return 'switch2';
+ if (!s.match(/^XA[JKW9][1479]/)) return 'invalid';
- const region = s[2];
- const assemblyLine = parseInt(s[3]);
- const checkingValue = parseInt(s.slice(3, 10));
+ if (s.length >= 10 && s.length < 14) s = s.padEnd(14, 'X');
+ if (s.length !== 14) return 'invalid';
- if (region === 'K') return 'maybe';
- if (region === '9') return 'maybe';
+ const region = s[2];
+ const assemblyLine = parseInt(s[3]);
+ const checkingValue = parseInt(s.slice(3, 10));
- if (region === 'J') {
- if (assemblyLine === 1) {
- if (checkingValue < 1002000) return 'unpatched';
- if (checkingValue < 1003000) return 'maybe';
- return 'patched'
- } else if (assemblyLine === 4) {
- if (checkingValue < 4004400) return 'unpatched';
- if (checkingValue < 4008300) return 'maybe';
- return 'patched'
- } else if (assemblyLine === 7) {
- if (checkingValue < 7004000) return 'unpatched';
- if (checkingValue < 7005000) return 'maybe';
- return 'patched'
+ if (region === 'K') return 'maybe';
+ if (region === '9') return 'maybe';
+
+ if (region === 'J') {
+ if (assemblyLine === 1) {
+ if (checkingValue < 1002000) return 'unpatched';
+ if (checkingValue < 1003000) return 'maybe';
+ return 'patched'
+ } else if (assemblyLine === 4) {
+ if (checkingValue < 4004400) return 'unpatched';
+ if (checkingValue < 4008300) return 'maybe';
+ return 'patched'
+ } else if (assemblyLine === 7) {
+ if (checkingValue < 7004000) return 'unpatched';
+ if (checkingValue < 7005000) return 'maybe';
+ return 'patched'
+ }
}
- }
- if (region === 'W') {
- if (assemblyLine === 1) {
- if (checkingValue < 1006500) return 'unpatched';
- if (checkingValue < 1012000) return 'maybe';
- return 'patched';
- } else if (assemblyLine === 4) {
- if (checkingValue < 4001100) return 'unpatched';
- if (checkingValue < 4001200) return 'maybe';
- return 'patched';
- } else if (assemblyLine === 7) {
- if (checkingValue < 7001750) return 'unpatched';
- if (checkingValue < 7003000) return 'maybe';
- return 'patched';
- } else if (assemblyLine === 9) {
- return 'maybe';
+ if (region === 'W') {
+ if (assemblyLine === 1) {
+ if (checkingValue < 1006500) return 'unpatched';
+ if (checkingValue < 1012000) return 'maybe';
+ return 'patched';
+ } else if (assemblyLine === 4) {
+ if (checkingValue < 4001100) return 'unpatched';
+ if (checkingValue < 4001200) return 'maybe';
+ return 'patched';
+ } else if (assemblyLine === 7) {
+ if (checkingValue < 7001750) return 'unpatched';
+ if (checkingValue < 7003000) return 'maybe';
+ return 'patched';
+ } else if (assemblyLine === 9) {
+ return 'maybe';
+ }
}
+
+ return 'invalid';
}
- return 'invalid';
-}
-
-const messages = {
- mariko: { type: 'warning', text: 'This appears to be a Mariko (V2) Switch or Switch Lite. These are patched and not hackable via software, only via hardware modchip. Find trusted hardmodders here.' },
- switch2: { type: 'danger', text: 'This appears to be a Switch 2. These are currently not hackable.' },
- refurb: { type: 'warning', text: 'This prefix belongs to officially refurbished Switch consoles, it might be patched. The only way to know for sure is to manually push a payload. Continue to this page.' },
- maybe: { type: 'warning', text: 'This serial might be patched. The only way to know for sure is to manually push a payload. Continue to this page.' },
- patched: { type: 'danger', text: 'This serial is patched. It is not hackable via software. Find trusted hardmodders here.' },
- unpatched: { type: 'tip', text: 'This serial is not patched! Click the following link to continue with the RCM path of the guide.' },
- invalid: { type: 'danger', text: 'This serial is invalid. Double-check you typed it correctly. At minimum, provide 6 digits after the prefix.' },
-}
-
-function redact(s) {
- if (s.length <= 9) return s;
- return s.slice(0, 9) + 'XXXX';
-}
-
-function outputResult(serial, {type, text}) {
- resultSerial.innerText = serial;
- resultText.innerHTML = text;
- result.classList = type;
-}
-
-
-function serialChangeEvent() {
- const d = digits.value.replace(/\D/g, '');
- const s = (prefix.value + d).toUpperCase();
-
- const earlyCheck = checkSerial(s.padEnd(14, 'X'));
- if (earlyCheck === 'mariko' || earlyCheck === 'switch2') {
- outputResult(prefix.value + "…", messages[earlyCheck]);
- return;
+ const messages = {
+ mariko: { type: 'warning', text: 'This appears to be a Mariko (V2) Switch or Switch Lite. These are patched and not hackable via software, only via hardware modchip. Find trusted hardmodders here.' },
+ switch2: { type: 'danger', text: 'This appears to be a Switch 2. These are currently not hackable.' },
+ refurb: { type: 'warning', text: 'This prefix belongs to officially refurbished Switch consoles, it might be patched. The only way to know for sure is to manually push a payload. Continue to this page.' },
+ maybe: { type: 'warning', text: 'This serial might be patched. The only way to know for sure is to manually push a payload. Continue to this page.' },
+ patched: { type: 'danger', text: 'This serial is patched. It is not hackable via software. Find trusted hardmodders here.' },
+ unpatched: { type: 'tip', text: 'This serial is not patched! Click the following link to continue with the RCM path of the guide.' },
+ invalid: { type: 'danger', text: 'This serial is invalid. Double-check you typed it correctly. At minimum, provide 6 digits after the prefix.' },
}
- if (prefix.value === 'XAW9') {
- outputResult(prefix.value + "…", messages.refurb);
- return;
+ function redact(s) {
+ if (s.length <= 9) return s;
+ return s.slice(0, 9) + 'XXXX';
}
- if (prefix.value === 'XAK1') {
- outputResult(prefix.value + "…", messages.maybe);
- return;
+ function outputResult(serial, {type, text}) {
+ resultSerial.innerText = serial;
+ resultText.innerHTML = text;
+ result.classList = type;
}
- if (d.length < 6) {
- result.classList = "serial-result-hidden";
- return;
+
+ function serialChangeEvent() {
+ const d = digits.value.replace(/\D/g, '');
+ const s = (prefix.value + d).toUpperCase();
+
+ const earlyCheck = checkSerial(s.padEnd(14, 'X'));
+ if (earlyCheck === 'mariko' || earlyCheck === 'switch2') {
+ outputResult(prefix.value + "…", messages[earlyCheck]);
+ return;
+ }
+
+ if (prefix.value === 'XAW9') {
+ outputResult(prefix.value + "…", messages.refurb);
+ return;
+ }
+
+ if (prefix.value === 'XAK1') {
+ outputResult(prefix.value + "…", messages.maybe);
+ return;
+ }
+
+ if (d.length < 6) {
+ result.classList = "serial-result-hidden";
+ return;
+ }
+
+ const key = checkSerial(s);
+ outputResult(redact(s), messages[key]);
}
- const key = checkSerial(s);
- outputResult(redact(s), messages[key]);
+ prefix.addEventListener("change", serialChangeEvent);
+ digits.addEventListener("input", serialChangeEvent);
}
-prefix.addEventListener("change", serialChangeEvent);
-digits.addEventListener("input", serialChangeEvent);
\ No newline at end of file
+if (document.readyState === "loading") {
+ document.addEventListener("DOMContentLoaded", initSerialChecker);
+} else {
+ initSerialChecker();
+}