Fix init order in RA mods

This commit is contained in:
Cohee 2024-04-11 22:47:28 +03:00
parent 3da9fb4efe
commit 16cabb38ad
1 changed files with 16 additions and 7 deletions

View File

@ -108,13 +108,22 @@ export function humanizeGenTime(total_gen_time) {
return time_spent; return time_spent;
} }
let parsedUA = null; /**
try { * DON'T OPTIMIZE, don't change this to a const or let, it needs to be a var.
parsedUA = Bowser.parse(navigator.userAgent); */
} catch { var parsedUA = null;
// In case the user agent is an empty string or Bowser can't parse it for some other reason
}
function getParsedUA() {
if (!parsedUA) {
try {
parsedUA = Bowser.parse(navigator.userAgent);
} catch {
// In case the user agent is an empty string or Bowser can't parse it for some other reason
}
}
return parsedUA;
}
/** /**
* Checks if the device is a mobile device. * Checks if the device is a mobile device.
@ -123,7 +132,7 @@ try {
export function isMobile() { export function isMobile() {
const mobileTypes = ['mobile', 'tablet']; const mobileTypes = ['mobile', 'tablet'];
return mobileTypes.includes(parsedUA?.platform?.type); return mobileTypes.includes(getParsedUA()?.platform?.type);
} }
export function shouldSendOnEnter() { export function shouldSendOnEnter() {