load-cordova.ts
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
console.log("[ loadCordova ] script loaded"); | |
// VERY HIGH CHANCE OF REGRESSION IN HERE | |
// IF VENDOR CHANGES USER-AGENT STRING | |
const userAgent = window.navigator.userAgent.toLowerCase(); | |
const safari = /safari/.test(userAgent); | |
const applewebkit = /applewebkit/.test(userAgent); | |
const mobileDescriptor = /mobile/.test(userAgent); | |
const ios = /iphone|ipod|ipad/.test(userAgent); | |
const ipadOs = applewebkit && mobileDescriptor; | |
const androidWebview = userAgent.includes("wv"); | |
function loadCordova() { | |
console.log("[ loadCordova ] loadCordova() start "); | |
var head = document.getElementsByTagName("head")[0]; | |
var js = document.createElement("script"); | |
js.type = "text/javascript"; | |
js.src = "cordova.js"; | |
head.appendChild(js); | |
console.log("[ loadCordova ] loadCordova() end"); | |
} | |
if (ios || ipadOs || androidWebview) { | |
loadCordova(); | |
} else { | |
console.log("[ loadCordova ] on a desktop browser, do nothing"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment