-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## NORMALIZE LINKS | ||
Just replaces ```youtube.com/redirect``` links with the real one. Mostly pointless though. | ||
## HOW TO USE | ||
1. Install the Tampermonkey extension. ([Link](https://www.tampermonkey.net)) | ||
2. [Install](https://github.com/k3rielit/scripts/raw/main/youtube/normalize-links.user.js) | ||
## UPDATES | ||
If it breaks, I'll try fixing it | ||
|
||
(If youtube changes their use of class names, it will break. Which didn't happen to ```yt-formatted-string``` for a long time, but whatever...) | ||
|
||
Last tested: 2021.12.07. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// ==UserScript== | ||
// @name YT Normalize Links | ||
// @namespace yt_normalize_links | ||
// @version 1.0 | ||
// @description replaces external links with the actual url instead of youtube's own redirect page | ||
// @author k3rielit | ||
// @match *://*.youtube.com/watch?* | ||
// @icon https://www.google.com/s2/favicons?domain=youtube.com | ||
// @grant none | ||
// ==/UserScript== | ||
|
||
(function() { | ||
'use strict'; | ||
const callback = () => { | ||
let redirects = [...document.getElementsByClassName('yt-formatted-string')].filter(f => f.href && f.href.startsWith('https://www.youtube.com/redirect')); | ||
redirects.forEach(a => { | ||
let decode = decodeURIComponent(a.href.split('q=')[1]); | ||
a.href = decode; | ||
a.innerText = decode.length > 100 ? decode.substring(0,100)+'...' : decode; | ||
}); | ||
}; | ||
const observer = new MutationObserver(callback); | ||
observer.observe(document.documentElement || document.body, { attributes: true, childList: true, subtree: true }); | ||
})(); |