Last active
February 4, 2024 13:14
-
-
Save steve228uk/0d40936eb27be445608a to your computer and use it in GitHub Desktop.
Deeplink Youtube
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
window.onload = function() { | |
var desktopFallback = "https://youtube.com/watch?v=4KnNVK-udTU", | |
mobileFallback = "https://youtube.com/watch?v=4KnNVK-udTU", | |
app = "vnd.youtube://4KnNVK-udTU"; | |
if( /Android|iPhone|iPad|iPod/i.test(navigator.userAgent) ) { | |
window.location = app; | |
window.setTimeout(function() { | |
window.location = mobileFallback; | |
}, 25); | |
} else { | |
window.location = desktopFallback; | |
} | |
function killPopup() { | |
window.removeEventListener('pagehide', killPopup); | |
} | |
window.addEventListener('pagehide', killPopup); | |
}; | |
</script> | |
</body> | |
</html> |
This is great, thanks.
I've been using it for a while, it worked perfectly, now it's working except on Facebook, it doesn't even fallback to the webpage, just loads white blank page! Any ideas?
Can we do something like this for other apps? Like Instagram, Facebook, Twitter etc?
Thank you, the code works great on Android and iPhone
https://www.facebook.com/as7aby/posts/10228785413441705?__cft__[0]=AZV90WiqjECtqm4Jo282HQC88-oY87Ui8kuWbjj5wW6sSFtZDmB8vRtMm_RQvANEcfsdBn4Cmbnw1XN0KcqHBLGmUcgoj7hyB6VnW3UeYwd7_Zv6HhP6T6MB8Z-f0fHOP2g&__tn__=%2CO%2CP-R
Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looking for a way to deeplink YT for free, found this. So does this need to be hosted on a domain and then will take the viewer straight to the app?