diff options
-rw-r--r-- | misc/old-reddit-page-cleanup.js | 6 | ||||
-rw-r--r-- | misc/piped-preferences.js | 44 | ||||
-rw-r--r-- | misc/rateyourmusic.com-dark-reader-compatibility.js | 16 | ||||
-rw-r--r-- | misc/reddit-redirect-to-old-reddit.js | 2 | ||||
-rw-r--r-- | misc/usps-fill-out-scheduled-pickup.js | 102 | ||||
-rw-r--r-- | youtube/disable-mini-player.js | 24 | ||||
-rw-r--r-- | youtube/piped-button.js | 86 | ||||
-rw-r--r-- | youtube/remove-home-shorts.js | 44 |
8 files changed, 154 insertions, 170 deletions
diff --git a/misc/old-reddit-page-cleanup.js b/misc/old-reddit-page-cleanup.js index 9326744..ab4007a 100644 --- a/misc/old-reddit-page-cleanup.js +++ b/misc/old-reddit-page-cleanup.js @@ -24,10 +24,10 @@ console.log(sidebar) sidebar.style.float = "none" sidebar.style.margin = "25px" while (sidebar.children[1]) - sidebar.children[1].remove() + 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) + const pre = c.parentElement.parentElement.insertBefore(document.createElement("pre"), c.parentElement) + pre.appendChild(c) }) diff --git a/misc/piped-preferences.js b/misc/piped-preferences.js index 0c7fffe..a168418 100644 --- a/misc/piped-preferences.js +++ b/misc/piped-preferences.js @@ -10,34 +10,34 @@ // all skip options (if any are to be set) must be present to avoid player errors const skipOptionsDefault = { - sponsor: "auto", - intro: "no", - outro: "no", - preview: "no", - interaction: "auto", - selfpromo: "auto", - music_offtopic: "auto", - poi_highlight: "no", - filler: "no" + sponsor: "auto", + intro: "no", + outro: "no", + preview: "no", + interaction: "auto", + selfpromo: "auto", + music_offtopic: "auto", + poi_highlight: "no", + filler: "no" } // fill localStorage { key: value } with preferred options // any preferences not filled will be default const prefs = { - bufferGoal: 30, - dearrow: true, - enabledCodecs: "avc", - homepage: "feed", - quality: 720, - showWatchOnYouTube: true, - watchHistory: true, - skipOptions: JSON.stringify({...skipOptionsDefault, ...{ - intro: "auto", - poi_highlight: "button", - filler: "button", - }}), + bufferGoal: 30, + dearrow: true, + enabledCodecs: "avc", + homepage: "feed", + quality: 720, + showWatchOnYouTube: true, + watchHistory: true, + skipOptions: JSON.stringify({...skipOptionsDefault, ...{ + intro: "auto", + poi_highlight: "button", + filler: "button", + }}), } // setup localStorage for (const [key, value] of Object.entries(prefs)) - localStorage.setItem(key, value) + localStorage.setItem(key, value) diff --git a/misc/rateyourmusic.com-dark-reader-compatibility.js b/misc/rateyourmusic.com-dark-reader-compatibility.js index 587fd7d..e2c20c2 100644 --- a/misc/rateyourmusic.com-dark-reader-compatibility.js +++ b/misc/rateyourmusic.com-dark-reader-compatibility.js @@ -9,12 +9,12 @@ // ==/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; } + .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/misc/reddit-redirect-to-old-reddit.js b/misc/reddit-redirect-to-old-reddit.js index 0b45467..3f645dc 100644 --- a/misc/reddit-redirect-to-old-reddit.js +++ b/misc/reddit-redirect-to-old-reddit.js @@ -14,4 +14,4 @@ // ==/UserScript== if (!location.hostname.startsWith("old")) - location.hostname = "old.reddit.com" + location.hostname = "old.reddit.com" diff --git a/misc/usps-fill-out-scheduled-pickup.js b/misc/usps-fill-out-scheduled-pickup.js index a8359ce..dd4256f 100644 --- a/misc/usps-fill-out-scheduled-pickup.js +++ b/misc/usps-fill-out-scheduled-pickup.js @@ -10,14 +10,14 @@ /* First page config */ const fill = { - emailAddress: "youremail@example.com", - phoneNumber: "777-777-7777", - zipCode: "60606", - state: "IL", - city: "CHICAGO", - addressLineOne: "701 My Lovely Home St.", - lastName: "Smith", - firstName: "John" + emailAddress: "youremail@example.com", + phoneNumber: "777-777-7777", + zipCode: "60606", + state: "IL", + city: "CHICAGO", + addressLineOne: "701 My Lovely Home St.", + lastName: "Smith", + firstName: "John" } /* Misc config */ @@ -25,83 +25,83 @@ const packageLocationFill = "Porch" /* Fill funcs */ function fillInitialFields() { - for (let fieldName in fill) - document.getElementById(fieldName).value = fill[fieldName] + for (let fieldName in fill) + document.getElementById(fieldName).value = fill[fieldName] } function fillDogField() { - const f = document.querySelector("#second-radio-verification[name=isDogHere]") - f.checked = true - return f + const f = document.querySelector("#second-radio-verification[name=isDogHere]") + f.checked = true + return f } function fillPackageLocation() { - const f = document.getElementById("packageLocation") - f.value = packageLocationFill - return f + const f = document.getElementById("packageLocation") + f.value = packageLocationFill + return f } function fillPickupTime() { - const f = document.getElementById("pickup-regular-time") - f.click() - return f + const f = document.getElementById("pickup-regular-time") + f.click() + return f } function fillPickupDate() { - const f = document.querySelector("#schedule-pickup-cal td:not(.ui-datepicker-unselectable)") // Gets first date that is selectable - f.click() - return f + const f = document.querySelector("#schedule-pickup-cal td:not(.ui-datepicker-unselectable)") // Gets first date that is selectable + f.click() + return f } function fillTerms() { - const f = document.querySelector(".termsConditions") - f.checked = true - return f + const f = document.querySelector(".termsConditions") + f.checked = true + return f } function fillHazmat() { - const f = document.querySelector("#hazmat-no") - f.checked = true - return f + const f = document.querySelector("#hazmat-no") + f.checked = true + return f } function scrollToDetails() { - document.getElementById("quantityCheck").scrollIntoView() + 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 month = parseInt(pickupDateTD.dataset.month) + 1 + const year = pickupDateTD.dataset.year + const day = pickupDateTD.firstElementChild.innerText - const date = `${month}-${day}-${year}` + const date = `${month}-${day}-${year}` - const dateElement = document.createElement("div") - dateElement.class = "step-four-top-header" - dateElement.innerHTML = `<p class="step-four-row-header"></p>` - dateElement.innerHTML += `<p class="step-four-row-header" style="font-weight:bold;">Date of Pickup: ${date}</p>` + const dateElement = document.createElement("div") + dateElement.class = "step-four-top-header" + dateElement.innerHTML = `<p class="step-four-row-header"></p>` + dateElement.innerHTML += `<p class="step-four-row-header" style="font-weight:bold;">Date of Pickup: ${date}</p>` - 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 + 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", () => { - const magicChange = new Event("change") + const magicChange = new Event("change") - fillDogField() .dispatchEvent(magicChange) - fillPackageLocation().dispatchEvent(magicChange) + fillDogField() .dispatchEvent(magicChange) + fillPackageLocation().dispatchEvent(magicChange) - fillPickupTime() // Works through click + 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) + 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/youtube/disable-mini-player.js b/youtube/disable-mini-player.js index da8349c..126a6a7 100644 --- a/youtube/disable-mini-player.js +++ b/youtube/disable-mini-player.js @@ -7,25 +7,25 @@ // Remove home and shorts button GM_addStyle(` - ytd-miniplayer, - .ytp-miniplayer-button - { - display: none !important; /* Needs !important flag */ - } + 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() + 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 + 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/youtube/piped-button.js b/youtube/piped-button.js index fd4b331..60cd7f2 100644 --- a/youtube/piped-button.js +++ b/youtube/piped-button.js @@ -18,62 +18,46 @@ const instanceUrl = `${instanceProtocol}//${instanceHostname}` const redirectButtonId = "piped-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%; } + 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}` + 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 = "Piped" - - 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) - /* - const actionDiv = document.querySelector("#actions #menu") - - const pipedLink = actionDiv.appendChild(document.createElement("a")) - pipedLink.id = "piped" - pipedLink.href = `${document.location.protocol}//${pipedInstance}${document.location.pathname}${document.location.search}` - - const pipedButton = pipedLink.appendChild(document.createElement("button")) // Simplify styling - - const pipedLogo = pipedButton.appendChild(document.createElement("img")) - pipedLogo.src = `${document.location.protocol}//${pipedInstance}/img/icons/logo.svg` - pipedLogo.alt = "(Down)" // Indicates instance is down if logo cannot be loaded - - const pipedText = pipedButton.appendChild(document.createElement("span")) - pipedText.innerText = "Piped" - */ - }, 500) // Wait 500ms for page load to finish after event called - }) + 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 = "Piped" + + 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/youtube/remove-home-shorts.js b/youtube/remove-home-shorts.js index a5e3634..42ea0d0 100644 --- a/youtube/remove-home-shorts.js +++ b/youtube/remove-home-shorts.js @@ -12,13 +12,13 @@ // 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 */ - } + 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 */ + } `) @@ -26,19 +26,19 @@ GM_addStyle(` 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) + // 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() + if (window.location.pathname === "/") + redirectToSubscriptions() } redirectIfHome() @@ -52,11 +52,11 @@ window.addEventListener("popstate", redirectIfHome) 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() - }) + 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() + }) } |