From 2832f5ebb6445d9de209b96ae6b9786f6e91f2dd Mon Sep 17 00:00:00 2001 From: SinTan1729 Date: Sun, 15 Oct 2023 15:45:43 -0500 Subject: [PATCH] new: Added youtube2piped.user.js --- youtube2piped.user.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 youtube2piped.user.js diff --git a/youtube2piped.user.js b/youtube2piped.user.js new file mode 100644 index 0000000..2a6baca --- /dev/null +++ b/youtube2piped.user.js @@ -0,0 +1,32 @@ +// ==UserScript== +// @name YouTube2Piped +// @namespace YouTube +// @version 1.1 +// @description Redirect YouTube to chosen Piped instance +// @author SinTan +// @match *://*.youtube.com/* +// @match *://youtu.be/* +// @icon https://raw.githubusercontent.com/TeamPiped/Piped/32e7ddaaff22f4a6c0d7f6359400323da7fefd69/public/img/icons/logo.svg +// @grant none +// @run-at document-start +// @license GPL-3.0 +// ==/UserScript== + +(function () { + "use strict"; + // Edit instance url here to go to any instance of choice + const instance = "https://piped.syncpundit.io" + + const url = new URL(window.location.href.replace('/shorts/', '/watch?v=')); + + let id = url.searchParams.get('v'); + let ts = url.searchParams.get('t'); + if (id) { + let url_new = instance + '/watch?v=' + id; + if (ts) { + url_new = url_new + '&t=' + ts; + } + window.location.replace(url_new); + } +} +)(); \ No newline at end of file