Skip to content

Commit

Permalink
YT Swap now replaces redirect links
Browse files Browse the repository at this point in the history
  • Loading branch information
k3rielit committed Jun 11, 2023
1 parent 1865bf1 commit 38ab89a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion youtube/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion youtube/swap.user.js
Original file line number Diff line number Diff line change
@@ -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==

Expand Down Expand Up @@ -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');
});
});
}
})();

0 comments on commit 38ab89a

Please sign in to comment.