From b88ff9fe8e80cc4d8aa0db2a3595ab10f40f4439 Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Mon, 21 Sep 2026 23:18:15 -0500 Subject: move all scripts to scripts dir --- scripts/old-reddit-page-cleanup.user.js | 35 +++++ ...rateyourmusic-dark-reader-compatibility.user.js | 22 ++++ scripts/usps-fill-out-scheduled-pickup.user.js | 145 +++++++++++++++++++++ scripts/youtube-disable-mini-player.user.js | 35 +++++ scripts/youtube-embedtube-button.user.js | 65 +++++++++ scripts/youtube-remove-home-shorts.user.js | 64 +++++++++ 6 files changed, 366 insertions(+) create mode 100644 scripts/old-reddit-page-cleanup.user.js create mode 100644 scripts/rateyourmusic-dark-reader-compatibility.user.js create mode 100644 scripts/usps-fill-out-scheduled-pickup.user.js create mode 100644 scripts/youtube-disable-mini-player.user.js create mode 100644 scripts/youtube-embedtube-button.user.js create mode 100644 scripts/youtube-remove-home-shorts.user.js (limited to 'scripts') diff --git a/scripts/old-reddit-page-cleanup.user.js b/scripts/old-reddit-page-cleanup.user.js new file mode 100644 index 0000000..70905ab --- /dev/null +++ b/scripts/old-reddit-page-cleanup.user.js @@ -0,0 +1,35 @@ +// ==UserScript== +// @name old.reddit.com page cleanup +// @namespace Violentmonkey Scripts +// @match https://old.reddit.com/* +// @grant none +// @homepageURL https://git.tjkeller.xyz/userscripts/about +// @downloadURL https://git.tjkeller.xyz/userscripts/plain/scripts/old-reddit-page-cleanup.user.js +// @version 1.1 +// @author tjkeller.xyz +// @description 10/20/2024, 7:22:44 PM +// ==/UserScript== + +/* remove top welcome banner */ +document.querySelector("section").remove() + +/* remove login prompt above comments */ +document.querySelector("section").remove() + +/* remove user sidebar */ +document.body.parentElement.style.paddingRight = 0 +document.getElementById("header-bottom-right").remove() + +/* remove most of the sidebar */ +const sidebar = document.querySelector("div.side") +console.log(sidebar) +sidebar.style.float = "none" +sidebar.style.margin = "25px" +while (sidebar.children[1]) + sidebar.children[1].remove() + +/* wrap code in pre instead of p */ +document.querySelectorAll("code").forEach(c => { + const pre = c.parentElement.parentElement.insertBefore(document.createElement("pre"), c.parentElement) + pre.appendChild(c) +}) diff --git a/scripts/rateyourmusic-dark-reader-compatibility.user.js b/scripts/rateyourmusic-dark-reader-compatibility.user.js new file mode 100644 index 0000000..a8d6090 --- /dev/null +++ b/scripts/rateyourmusic-dark-reader-compatibility.user.js @@ -0,0 +1,22 @@ +// ==UserScript== +// @name rateyourmusic.com darkmode compat +// @namespace Violentmonkey Scripts +// @match https://rateyourmusic.com/* +// @grant GM_addStyle +// @homepageURL https://git.tjkeller.xyz/userscripts/about +// @downloadURL https://git.tjkeller.xyz/userscripts/plain/scripts/rateyourmusic-dark-reader-compatibility.user.js +// @version 1.1 +// @author tjkeller.xyz +// @description 7/9/2024, 10:34:17 PM +// ==/UserScript== + +GM_addStyle(` + .page_charts_section_charts_item_details_average_num { background: var(--average-rating); -webkit-background-clip: text; } + .page_home_intro_content_text_sitename, + .disco_avg_rating { background-clip: text !important; } + #column_container_right *, + .disco_expand_section_btn { background: #111 !important; } + #ui_search_input_main_search { background: #252525; } + .page_home_section_featured_content_content_item .page_section_dynamic_fade_cover { background: linear-gradient(to bottom,rgba(128,128,128,0),#212121); } + .ui_button { background: 444 !important; } +`) diff --git a/scripts/usps-fill-out-scheduled-pickup.user.js b/scripts/usps-fill-out-scheduled-pickup.user.js new file mode 100644 index 0000000..a9a44d2 --- /dev/null +++ b/scripts/usps-fill-out-scheduled-pickup.user.js @@ -0,0 +1,145 @@ +// ==UserScript== +// @name Fill out usps scheduled pickup +// @namespace Violentmonkey Scripts +// @match https://tools.usps.com/schedule-pickup-steps.htm* +// @grant GM_getValue +// @grant GM_setValue +// @grant GM_registerMenuCommand +// @homepageURL https://git.tjkeller.xyz/userscripts/about +// @downloadURL https://git.tjkeller.xyz/userscripts/plain/scripts/usps-fill-out-scheduled-pickup.user.js +// @version 2.0 +// @author tjkeller.xyz +// @description 2/11/2024, 7:23:34 PM +// ==/UserScript== + +/* Save/load data */ +const initialFields = [ + "addressLineOne", + "addressLineTwo", + "city", + "emailAddress", + "firstName", + "isBusinessAddress", + "lastName", + "middleInitial", + "phoneExt", + "phoneNumber", + "state", + "zipCode", +] +const otherFields = [ + "first-radio-verification", + "packageLocation", + "second-radio-verification", + "step-two-desc-item-textarea", +] +function isCheckable(input) { return input.type == "checkbox" || input.type == "radio" } +function saveFilledData(key, fieldNames) { + const data = {} + for (let fieldName of fieldNames) { + const input = document.getElementById(fieldName) + if (!input) { + //alert(`Failed to save. Not all fields are filled. Make sure to continue after "Check Availability"`) + alert(`Field "${fieldName}" not found`) + return false + } + const label = input.previousElementSibling + const required = label ? label.innerText.startsWith("*") : false // inputs not marked required + data[fieldName] = isCheckable(input) ? input.checked : input.value + if (required && !data[fieldName]) { + input.focus() + alert(`Failed to save. Missing required data for "${label.innerText.substring(1)}"`) + return false + } + } + GM_setValue(key, data) + alert(`Saved successfully. Reload to check`) + return true +} + +GM_registerMenuCommand("Save Step 1 Fields", () => saveFilledData("initialFields", initialFields)) +GM_registerMenuCommand("Save Step 2 Fields", () => saveFilledData("otherFields", otherFields)) + +/* Fill funcs */ +const magicChange = new Event("change") +function fillFields(data) { + for (let fieldName in data) { + const input = document.getElementById(fieldName) + if (isCheckable(input)) + input.checked = data[fieldName] + else + input.value = data[fieldName] + input.dispatchEvent(magicChange) + } +} +function fillInitialFields() { + const data = GM_getValue("initialFields", {}) + fillFields(data) +} + +function fillOtherFields() { + const data = GM_getValue("otherFields", {}) + fillFields(data) +} + +function fillPickupTime() { + const f = document.getElementById("pickup-regular-time") + f.click() + return f +} + +function fillPickupDate() { + const f = document.querySelector("#schedule-pickup-cal td:not(:first-child):not(.ui-datepicker-unselectable):not(.holiday):not(.ui-state-disabled)") // Gets first date that is selectable + f.click() + return f +} + +function fillTerms() { + const f = document.querySelector(".termsConditions") + f.checked = true + return f +} + +function fillHazmat() { + const f = document.querySelector("#hazmat-no") + f.checked = true + return f +} + +function scrollToDetails() { + document.getElementById("quantityCheck").scrollIntoView() +} + +function showPickupDateInStepFour(pickupDateTD) { + const month = parseInt(pickupDateTD.dataset.month) + 1 + const year = pickupDateTD.dataset.year + const day = pickupDateTD.firstElementChild.innerText + + const date = `${month}-${day}-${year}` + + const dateElement = document.createElement("div") + dateElement.class = "step-four-top-header" + dateElement.innerHTML = `

` + dateElement.innerHTML += `Date of Pickup: ${date}` + + const container = document.querySelector("div.pickup-summary-gray-box-wrapper div") + const sibiling = container.querySelector("div.step-four-top-header") + container.insertBefore(dateElement, sibiling) + return dateElement +} + +/* Start */ +fillInitialFields() + +document.querySelector("#webToolsAddressCheck").addEventListener("click", () => { + fillOtherFields() + + fillPickupTime() // Works through click + + setTimeout(() => { + showPickupDateInStepFour(fillPickupDate()) // Need to wait for this (calendar) to load in first since it's loaded dynamically + fillHazmat() + fillTerms() + scrollToDetails() + }, 750) +}) diff --git a/scripts/youtube-disable-mini-player.user.js b/scripts/youtube-disable-mini-player.user.js new file mode 100644 index 0000000..1b02a24 --- /dev/null +++ b/scripts/youtube-disable-mini-player.user.js @@ -0,0 +1,35 @@ +// ==UserScript== +// @name Disable YouTube Miniplayer +// @author tjkeller.xyz +// @include *youtube.com* +// @grant GM_addStyle +// @homepageURL https://git.tjkeller.xyz/userscripts/about +// @downloadURL https://git.tjkeller.xyz/userscripts/plain/scripts/youtube-disable-mini-player.user.js +// @version 1.1 +// @author tjkeller.xyz +// ==/UserScript== + +// Remove home and shorts button +GM_addStyle(` + ytd-miniplayer, + .ytp-miniplayer-button + { + display: none !important; /* Needs !important flag */ + } +`) + + +// Pause video before navigating +document.body.addEventListener("yt-navigate-start", () => { + if (window.location.pathname == "/watch") + document.querySelector("ytd-player video").pause() +}) + +// Close miniplayer by clicking close button in code +document.body.addEventListener("yt-navigate-finish", () => { + setTimeout(() => { + const miniplayerCloseButton = document.querySelector("button.ytp-miniplayer-close-button") + if (miniplayerCloseButton) + miniplayerCloseButton.click() + }, 500) // Wait 500ms to close consistantly since miniplayer loads a little after this event +}) diff --git a/scripts/youtube-embedtube-button.user.js b/scripts/youtube-embedtube-button.user.js new file mode 100644 index 0000000..f168eb9 --- /dev/null +++ b/scripts/youtube-embedtube-button.user.js @@ -0,0 +1,65 @@ +// ==UserScript== +// @name Redirect to EmbedTube +// @namespace Violentmonkey Scripts +// @match https://www.youtube.com/* +// @grant GM_addStyle +// @homepageURL https://git.tjkeller.xyz/userscripts/about +// @downloadURL https://git.tjkeller.xyz/userscripts/plain/scripts/youtube-embedtube-button.user.js +// @version 1.1 +// @author tjkeller.xyz +// @description 3/9/2024, 8:38:47 PM +// ==/UserScript== + +/* Config */ +const instanceHostname = "yt.tjkeller.xyz" +const instanceProtocol = "https:" +const instanceIconLogo = "/static/favicon.svg" + +const instanceUrl = `${instanceProtocol}//${instanceHostname}` + +const redirectButtonId = "embedtube-button" + +GM_addStyle(` + a#${redirectButtonId} button { + background-color: #272727; + border-radius: 18px; + border: none; + color: white; + cursor: pointer; + display: flex; + font-family: "Roboto","Arial",sans-serif; + font-weight: 500; + height: 36px; + padding: .25em 1em .25em .65em; + text-decoration: none; + } + a#${redirectButtonId} button:hover { background-color: #3f3f3f; } + a#${redirectButtonId} button * { align-self: center; max-height: 100%; } +`) + + +function newUrl() { + return `${instanceProtocol}//${instanceHostname}${document.location.pathname}${document.location.search}` +} + +if (!document.getElementById(redirectButtonId)) { + const redirectButton = document.createElement("a") + const redirectButtonC = redirectButton.appendChild(document.createElement("button")) + const redirectButtonImg = redirectButtonC.appendChild(document.createElement("img")) + const redirectButtonTxt = redirectButtonC.appendChild(document.createElement("span")) + redirectButton.id = redirectButtonId + redirectButtonImg.src = instanceUrl + instanceIconLogo + redirectButtonImg.alt = "(Down)" // Logo effectively acts as a test to see whether the instance is up or not as a bonus + redirectButtonTxt.innerText = "EmbedTube" + + redirectButton.addEventListener("mouseover", () => { redirectButton.href = newUrl() }) + + /* Insert */ + document.body.addEventListener("yt-navigate-finish", () => { + + setTimeout(() => { + const headContainer = document.querySelector("#masthead-container #container #start") + headContainer.appendChild(redirectButton) + }, 500) // Wait 500ms for page load to finish after event called + }) +} diff --git a/scripts/youtube-remove-home-shorts.user.js b/scripts/youtube-remove-home-shorts.user.js new file mode 100644 index 0000000..5e75ef1 --- /dev/null +++ b/scripts/youtube-remove-home-shorts.user.js @@ -0,0 +1,64 @@ +// ==UserScript== +// @name Remove youtube home and shorts +// @namespace Violentmonkey Scripts +// @include *youtube.com* +// @grant GM_addStyle +// @homepageURL https://git.tjkeller.xyz/userscripts/about +// @downloadURL https://git.tjkeller.xyz/userscripts/plain/scripts/youtube-remove-home-shorts.user.js +// @version 1.1 +// @author tjkeller.xyz +// @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() + }) +} -- cgit v1.3.1