mirror of
https://github.com/SinTan1729/userscripts.git
synced 2025-02-05 14:12:32 -06:00
feat: Support @channel links
This commit is contained in:
parent
0c683ed5dd
commit
c011766cdc
1 changed files with 3 additions and 3 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue