Skip to content

Instantly share code, notes, and snippets.

@steve228uk
Last active February 4, 2024 13:14
Show Gist options
  • Star 32 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save steve228uk/0d40936eb27be445608a to your computer and use it in GitHub Desktop.
Save steve228uk/0d40936eb27be445608a to your computer and use it in GitHub Desktop.
Deeplink Youtube
<!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>
@YasserTamer
Copy link

It works fine with me as well. But when I share it, it appear as coming from my domain. While people using professional deep linking portal the link appear as being from youtube with the same Thumbnail. I wonder if the code can be modified so the shared post looks the same

@benjaminwtwall
Copy link

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?

@bassel999
Copy link

The code is working great
But only on chrome browser on Android it will not work.
Any advice?

@M7ammad-eb
Copy link

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?

@viwicodes
Copy link

Can we do something like this for other apps? Like Instagram, Facebook, Twitter etc?

@necipsagiro
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment