Skip to content

Instantly share code, notes, and snippets.

@asportnoy
Last active September 30, 2024 02:17
Show Gist options
  • Save asportnoy/628b820184297f5fe296c1a5b79c8000 to your computer and use it in GitHub Desktop.
Save asportnoy/628b820184297f5fe296c1a5b79c8000 to your computer and use it in GitHub Desktop.
Open Youtube App Userscript | See https://github.com/qnblackcat/uYouPlus/issues/69
// ==UserScript==
// @name Open YouTube App
// @version 1.0.4
// @author asportnoy
// @match *://*.youtube.com/*
// @downloadURL https://gist.github.com/asportnoy/628b820184297f5fe296c1a5b79c8000/raw/open-youtube-app.user.js
// @updateURL https://gist.github.com/asportnoy/628b820184297f5fe296c1a5b79c8000/raw/open-youtube-app.user.js
// @homepage https://gist.github.com/asportnoy/628b820184297f5fe296c1a5b79c8000/
// @inject-into content
// ==/UserScript==
if (window.self !== window.top) return; // iframe
if (window.location.pathname === '/redirect') return; // Opening link in browser from app
window.location.href = `youtube://${window.location.pathname.slice(1)}${
window.location.search
}${window.location.hash}`;
@tonysprenk
Copy link

I have downloaded the userscript extension, I have enabled it, I have set the userscript directory, I have downloaded the above script to the directory. When I open a YouTube link I don’t get the open in YouTube pop-up, what am I doing wrong?

@asportnoy
Copy link
Author

Go to youtube.com, open the extension, and make sure it shows up in the list
46DF39C7-2579-4198-B6BF-9898DABE90A3

@tonysprenk
Copy link

Yup, it’s working now. Great solution!

@IdirisDT
Copy link

Sorry if this is a dumb question but how do I install this? I have the Userscripts extension turned on and with the correct folder but when I try download this I just get an html file that does nothing

@asportnoy
Copy link
Author

@IdirisDT Press the “raw” button above, then open the extension and it should show an install button. This didn’t work before due to an issue with the file name but that is now fixed.

@IdirisDT
Copy link

Thank you. That did the trick.

@tacoyako
Copy link

tacoyako commented May 4, 2022

it possible to have the script for instagram app?

@movieman12341
Copy link

movieman12341 commented Jun 18, 2022

Does this currently work? It was working fine for me last week but it no longer works. As in, I see the userscript picture as [asportnoy] showed earlier in this thread, but I don't get the prompt to open in uyou. I reinstalled userscripts app, redownloaded this js script, and restarted phone. None of these worked. I'm on ios 15.5.

Edit: it now works. Apparently I needed to completely close the tab in safari and make a new tab. It has worked ever since.

@asportnoy
Copy link
Author

I recently fixed an issue where clicking a link in YouTube would prompt you to go back to YouTube, essentially making links in descriptions unusable.

Unfortunately, I messed up the update URL in the original version, so you’ll have to delete and redownload the script to get the update. That has also been fixed, so updating to future versions should be easier.

@lewiwiii
Copy link

lewiwiii commented Nov 5, 2022

can u do a spotify one?

@yodaluca23
Copy link

This is exactly what I’ve been wanting… Problem is my default browser isn’t safari but listen to my idea for a way to make it work, and that requires even less steps.

So couldn't someone theoretically publish an app to the Apple App Store (official) that can be set as your default browser, that when done so, any link opened from another app, would be sent to this app (because it's your "Browser"), and then (configurable in the app), the user could have it say, for example, open all youtube.com URLs in YouTube (sideloaded), so whenever it grabs that link because it's considered a web browser, it would then pass it off to YouTube, and then have it where if it's any other link not any of the ones that the user wants to be opened in a specific app to then pass it off to the user's real web browser of choice, again configurable in the app.

I don't know if this would be allowed on the App Store, I have no idea of Apple's rules on that kind of stuff, I've never tried this, and I'm not a Swift programer, but I think this could work if Apple allows it on the store.

@sevenc-nanashi
Copy link

This did not work on my Safari, so I patched this script: https://gist.github.com/sevenc-nanashi/83d7214c43e47f9f689a9199f81f0a8e

I hope this is useful.

@asportnoy
Copy link
Author

Updated script accordingly, should be working again. Thanks.

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