From 38ab89ad182d2571194eb564a55a9b207b1ed66d Mon Sep 17 00:00:00 2001 From: szialajoscosplay <70654182+k3rielit@users.noreply.github.com> Date: Sun, 11 Jun 2023 16:44:06 +0200 Subject: [PATCH] YT Swap now replaces redirect links --- youtube/README.md | 2 +- youtube/swap.user.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/youtube/README.md b/youtube/README.md index a4841aa..5da107f 100644 --- a/youtube/README.md +++ b/youtube/README.md @@ -4,9 +4,9 @@ Replaces the top left logo with something more useful: - [x] Switch between Shorts and Watch UI - [x] Smaller home button +- [x] Replace redirect links with real ones - [ ] [Return YouTube Dislike](https://returnyoutubedislike.com/docs) raw data popup - [ ] Display a [QR code](https://davidshimjs.github.io/qrcodejs/) for the video -- [ ] Replace redirect links with real ones ## Install diff --git a/youtube/swap.user.js b/youtube/swap.user.js index ce00aa5..713bcd3 100644 --- a/youtube/swap.user.js +++ b/youtube/swap.user.js @@ -1,13 +1,14 @@ // ==UserScript== // @name YT Swap // @namespace k3rielit.ytswap -// @version 1.0 +// @version 2.0 // @description Swaps between Shorts and Watch UI for the current video. // @author github.com/k3rielit // @match *://*.youtube.com/* // @match *://*.youtu.be/* // @icon https://www.google.com/s2/favicons?sz=64&domain=youtube.com // @grant none +// @updateURL https://github.com/k3rielit/scripts/raw/main/youtube/swap.user.js // @downloadURL https://github.com/k3rielit/scripts/raw/main/youtube/swap.user.js // ==/UserScript== @@ -95,6 +96,10 @@ function sleep(ms) { topLeftLogo.appendChild(stringToElement(components.buttonQRCode)); } } + // Replace redirect links + document.querySelectorAll('a[href*="https://www.youtube.com/redirect"]').forEach((elem,index) => { + elem.href = new URL(elem.href).searchParams.get('q'); + }); }); } })(); \ No newline at end of file