aboutsummaryrefslogtreecommitdiff
path: root/youtube/remove-home-shorts.js
diff options
context:
space:
mode:
authorTim Keller <tjkeller.xyz>2024-11-17 22:36:53 -0600
committerTim Keller <tjkeller.xyz>2024-11-17 22:36:53 -0600
commit6bb49cc16cbf03d4e0980c2343372ff20d0a4b55 (patch)
tree38b659a6081e639cce5bd4503886370a75c5c770 /youtube/remove-home-shorts.js
parentd7484069764fe74654fe5e7721919462bc1286d2 (diff)
downloaduserscripts-6bb49cc16cbf03d4e0980c2343372ff20d0a4b55.tar.xz
userscripts-6bb49cc16cbf03d4e0980c2343372ff20d0a4b55.zip
rename all scripts to have .user.js ext
Diffstat (limited to 'youtube/remove-home-shorts.js')
-rw-r--r--youtube/remove-home-shorts.js62
1 files changed, 0 insertions, 62 deletions
diff --git a/youtube/remove-home-shorts.js b/youtube/remove-home-shorts.js
deleted file mode 100644
index 42ea0d0..0000000
--- a/youtube/remove-home-shorts.js
+++ /dev/null
@@ -1,62 +0,0 @@
-// ==UserScript==
-// @name Remove youtube home and shorts
-// @namespace Violentmonkey Scripts
-// @include *youtube.com*
-// @grant GM_addStyle
-// @version 1.0
-// @author tjk918
-// @description 9/21/2023, 9:44:13 AM
-// @license MIT
-// ==/UserScript==
-
-
-// Remove home and shorts button
-GM_addStyle(`
- tp-yt-app-drawer a[title=Home],
- tp-yt-app-drawer a[title=Shorts],
- ytd-mini-guide-renderer a[title=Home],
- ytd-mini-guide-renderer a[title=Shorts]
- {
- display: none !important; /* Needs !important flag */
- }
-`)
-
-
-// Subscriptions page is new homepage
-const subscriptionsPath = "/feed/subscriptions"
-
-function redirectToSubscriptions() {
- // Invoke clicking the subscriptions button to use youtube's hot page reloading if possible instead of reloading the whole page
- const subscriptionsButton = document.querySelector("tp-yt-app-drawer a[title=Subscriptions]")
- if (subscriptionsButton)
- subscriptionsButton.click()
- else
- window.location.replace(subscriptionsPath)
-}
-
-
-// Redirect to new homepage
-function redirectIfHome() {
- if (window.location.pathname === "/")
- redirectToSubscriptions()
-}
-
-redirectIfHome()
-window.addEventListener("popstate", redirectIfHome)
-//document.body.addEventListener("yt-navigate-finish", redirectIfHome)
-
-
-// Youtube logo navigate to subscriptions
-/* Needs to be done safely in case youtube changes and also because it throws
- * an error otherwise because violentmonkey seems to load the script twice */
-
-const logo = document.querySelector("#logo a")
-if (logo) {
- logo.href = subscriptionsPath
- logo.addEventListener("click", e => {
- // Seems there is an event listener that forces redirect to site root, so stop that first
- e.stopPropagation()
- e.preventDefault()
- redirectToSubscriptions()
- })
-}