feat: Support @channel links

This commit is contained in:
Sayantan Santra 2023-10-27 02:54:34 -05:00
parent 0c683ed5dd
commit c011766cdc
Signed by: SinTan1729
GPG Key ID: EB3E68BFBA25C85F
1 changed files with 3 additions and 3 deletions

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name YouTube2Piped // @name YouTube2Piped
// @namespace YouTube // @namespace YouTube
// @version 1.2.0 // @version 1.2.1
// @description Redirect YouTube to chosen Piped instance // @description Redirect YouTube to chosen Piped instance
// @author SinTan // @author SinTan
// @match *://*.youtube.com/* // @match *://*.youtube.com/*
@ -29,11 +29,11 @@
window.location.replace(url_new); window.location.replace(url_new);
} else { } else {
let pattern = /https:\/\/www\.youtube\.com\/channel\/([A-Za-z0-9\_\-]+).*/; let pattern = /https:\/\/www\.youtube\.com\/((?:(?:channel\/)|\@)[A-Za-z0-9\_\-]+).*/;
let channelId = pattern.exec(url)[1]; let channelId = pattern.exec(url)[1];
if (channelId) { if (channelId) {
let url_new = instance + '/channel/' + channelId; let url_new = instance + '/' + channelId;
window.location.replace(url_new); window.location.replace(url_new);
} }
} }