Last active
December 19, 2023 13:35
-
-
Save ryuya0124/2ba4f56cf9e9dab781d3146c74a3f36b to your computer and use it in GitHub Desktop.
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
// ==UserScript== | |
// @name Open YouTube App | |
// @version 1.0.4 | |
// @author ryuya | |
// @match *://*.youtube.com/* | |
// @downloadURL https://gist.github.com/ryuya0124/2ba4f56cf9e9dab781d3146c74a3f36b/raw/36b9e3e13a95a4e323ff99b22b104bc61abaf764/open-youtube-app.user.js | |
// @updateURL https://gist.github.com/ryuya0124/2ba4f56cf9e9dab781d3146c74a3f36b/raw/36b9e3e13a95a4e323ff99b22b104bc61abaf764/open-youtube-app.user.js | |
// @homepage https://gist.github.com/ryuya0124/2ba4f56cf9e9dab781d3146c74a3f36b | |
// ==/UserScript== | |
if (window.location.pathname === '/redirect') return; | |
let targetUrl = ''; | |
if (window.location.pathname.startsWith('/@')) { | |
// Handle URLs with @username | |
const username = window.location.pathname.slice(2); | |
targetUrl = `youtube://www.youtube.com/@${username}${window.location.search}${window.location.hash}`; | |
} else { | |
// Handle regular video/channel URLs | |
targetUrl = `youtube://${window.location.pathname.slice(1)}${window.location.search}${window.location.hash}`; | |
} | |
window.location.href = targetUrl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment