From e53b138cce506b0c2a6f8bdccf09211180e45c1e Mon Sep 17 00:00:00 2001 From: adam Date: Tue, 7 Mar 2023 10:21:15 -0500 Subject: [PATCH] most of my current greasemonkey scripts --- greasemonkey/725984.js | 110 ++++++++++++++++++++++++ greasemonkey/Feed icon link.js | 40 +++++++++ greasemonkey/Newegg Bullshit Reducer.js | 22 +++++ greasemonkey/gmail please fuck off.js | 19 ++++ greasemonkey/imdb poster grab.js | 31 +++++++ greasemonkey/mtg plot reader view.js | 44 ++++++++++ 6 files changed, 266 insertions(+) create mode 100644 greasemonkey/725984.js create mode 100644 greasemonkey/Feed icon link.js create mode 100644 greasemonkey/Newegg Bullshit Reducer.js create mode 100644 greasemonkey/gmail please fuck off.js create mode 100644 greasemonkey/imdb poster grab.js create mode 100644 greasemonkey/mtg plot reader view.js diff --git a/greasemonkey/725984.js b/greasemonkey/725984.js new file mode 100644 index 0000000..c021145 --- /dev/null +++ b/greasemonkey/725984.js @@ -0,0 +1,110 @@ +// ==UserScript== +// @name 725984 +// @version 1 +// @grant none +// @include /^https?://([^\.]*\.)?twitch\.tv/(moderator/)?[^/]+$/ +// @description auto claim active bonus. should probably keep this secret? +// ==/UserScript== + +var reportToast = document.createElement("div"); +reportToast.id = "snackbar"; +var summaryObject = null; +var claimInterval = -1; +var summarySearch = setInterval(() => { + popToast("725984 is alive"); + //reportToast.appendChild(document.createTextNode()); + //document.body.appendChild(reportToast); + //reportToast.className = "show"; + console.log("725984 survived most of init"); + setInterval(function(){ reportToast.className = reportToast.className.replace("show", ""); }, 3000); + + summaryObject = document.querySelector(".community-points-summary"); + if(summaryObject !== null){ + popToast("725984: online"); + clearInterval(summarySearch); + claimInterval = setTimeout(claim, 1000 + Math.random() * 1000); + summaryObject.insertBefore(document.createTextNode("🟢"), summaryObject.firstChild) + } else { + console.log("725984: not ready"); + popToast("725984: not ready"); + } +}, 5000); + +function claim(){ + //look for claim. if found: + + summaryObject.querySelectorAll("button").forEach((elem) => { + //console.log(Date()); + let claimability = elem.querySelector(".claimable-bonus__icon"); + if(claimability !== null){ + console.log("725984: in motion"); + if(Math.random() < 0.1){ + popToast("725984 claims"); + elem.click(); + }else{ + popToast("725984 abstains"); + } + } + clearTimeout(claimInterval); + claimInterval = setTimeout(claim, 1000 + Math.random() * 1000); + }); + +} + +function popToast(msg){ + console.log(msg); + reportToast.innerHTML = ""; + reportToast.appendChild(document.createTextNode(msg)); + reportToast.className = "show"; +} + +let newStyle = document.createElement("style"); + newStyle.setAttribute("type", "text/css"); + newStyle.textContent = ` +#snackbar { + visibility: hidden; /* Hidden by default. Visible on click */ + min-width: 250px; /* Set a default minimum width */ + margin-left: -125px; /* Divide value of min-width by 2 */ + background-color: #333; /* Black background color */ + color: #fff; /* White text color */ + text-align: center; /* Centered text */ + border-radius: 2px; /* Rounded borders */ + padding: 16px; /* Padding */ + position: fixed; /* Sit on top of the screen */ + z-index: 1; /* Add a z-index if needed */ + right: 30px; /* near the right; where you'll be looking (probably) */ + bottom: 30px; /* 30px from the bottom */ +} + +/* Show the snackbar when clicking on a button (class added with JavaScript) */ +#snackbar.show { + visibility: visible; /* Show the snackbar */ + /* Add animation: Take 0.5 seconds to fade in and out the snackbar. + However, delay the fade out process for 2.5 seconds */ + -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s; + animation: fadein 0.5s, fadeout 0.5s 2.5s; +} + +/* Animations to fade the snackbar in and out */ +@-webkit-keyframes fadein { + from {bottom: 0; opacity: 0;} + to {bottom: 30px; opacity: 1;} +} + +@keyframes fadein { + from {bottom: 0; opacity: 0;} + to {bottom: 30px; opacity: 1;} +} + +@-webkit-keyframes fadeout { + from {bottom: 30px; opacity: 1;} + to {bottom: 0; opacity: 0;} +} + +@keyframes fadeout { + from {bottom: 30px; opacity: 1;} + to {bottom: 0; opacity: 0;} +} +`; +document.head.appendChild(newStyle); +document.body.appendChild(reportToast); \ No newline at end of file diff --git a/greasemonkey/Feed icon link.js b/greasemonkey/Feed icon link.js new file mode 100644 index 0000000..a0b792e --- /dev/null +++ b/greasemonkey/Feed icon link.js @@ -0,0 +1,40 @@ +// ==UserScript== +// @name Feed icon link +// @version 1 +// @grant none +// @description youtube does publish rss feeds. But it's not the easiest thing in the world to find. +// @include /^https?://(www\.)?youtube.com\/watch\?/ +// @namespace adamrgrey.com +// @license MIT +// ==/UserScript== + +//from wikipedia: https://en.wikipedia.org/wiki/File:Feed-icon.svg, but it's gnu. +let svgsrc = ` + + + + + + + + + + + + + + + + +`.trim(); + + +setTimeout(() => { + let feedLink = document.createElement("a"); + feedLink.setAttribute("href", "https://www.youtube.com/feeds/videos.xml?channel_id=" + document.body.querySelector("meta[itemprop=channelId]").content); + feedLink.innerHTML = svgsrc; + document.querySelectorAll(".ytd-subscribe-button-renderer").forEach((elem) => { + elem.parentElement.appendChild(feedLink); + + }); +}, 1500); \ No newline at end of file diff --git a/greasemonkey/Newegg Bullshit Reducer.js b/greasemonkey/Newegg Bullshit Reducer.js new file mode 100644 index 0000000..eafb01e --- /dev/null +++ b/greasemonkey/Newegg Bullshit Reducer.js @@ -0,0 +1,22 @@ +// ==UserScript== +// @name Newegg Bullshit Reducer +// @version 1 +// @grant none +// @match *://*.newegg.com/* +// @description you MOTHERFUCKER +// @namespace adamrgrey.com +// @license MIT +// ==/UserScript== + +function killit(){ + let target = document.querySelector(".newegg-notification"); + if(target !== null){ + console.log("found, removing"); + target.remove(); + clearInterval(checkInterval); + } +} + + +var checkInterval = setInterval(killit, 1000); +killit(); \ No newline at end of file diff --git a/greasemonkey/gmail please fuck off.js b/greasemonkey/gmail please fuck off.js new file mode 100644 index 0000000..8acc825 --- /dev/null +++ b/greasemonkey/gmail please fuck off.js @@ -0,0 +1,19 @@ +// ==UserScript== +// @name gmail please fuck off +// @version 1 +// @grant none +// @include /^https?://mail.google.com/ +// @require https://code.jquery.com/jquery-3.4.1.min.js +// @require https://gist.githubusercontent.com/BrockA/2625891/raw/9c97aa67ff9c5d56be34a55ad6c18a314e5eb548/waitForKeyElements.js +// ==/UserScript== + +function onBannerFound(){ + console.log("found something"); + $("p:contains(This message was not sent to Spam because of a filter you created)").each(function(idx, elem){ + console.log("removing a parent of:"); + console.log(elem); + $(elem).parent().parent().remove(); + }); +} + +waitForKeyElements("p:contains(This message was not sent to Spam because of a filter you created)", onBannerFound); \ No newline at end of file diff --git a/greasemonkey/imdb poster grab.js b/greasemonkey/imdb poster grab.js new file mode 100644 index 0000000..7bf4e50 --- /dev/null +++ b/greasemonkey/imdb poster grab.js @@ -0,0 +1,31 @@ +// ==UserScript== +// @name imdb poster grab +// @version 1 +// @grant none +// @namespace adamrgrey.com +// @license MIT +// @description don't know why imdb makes it so hard to grab the movie's own advertising. they want it to spread. it's advertising. +// @include /^https?://(www\.)?imdb.com\/title\// +// ==/UserScript== + + +setTimeout(() => { + //console.log("searching for imdb poster"); + let srcset = document.querySelector(".ipc-media--poster-l img").getAttribute("srcset").split(', '); + //console.log("srcs: ", srcset.length); + let biggestW = 0; + let biggestUri = ""; + srcset.forEach((elem) => { + let splitUp = elem.split(' '); + let last = splitUp[splitUp.length - 1]; + let numVal = Number(last.match(/\d+/)[0]); + if(numVal > biggestW){ + biggestUri = splitUp[0]; + } + }); + //console.log("chose " + biggestUri + " because " + biggestW + " seems biggest"); + let feedLink = document.createElement("a"); + feedLink.setAttribute("href",biggestUri); + feedLink.innerHTML = "poster plz"; + document.querySelector(".ipc-media--poster-l").parentElement.parentElement.parentElement.parentElement.appendChild(feedLink); +}, 1500); diff --git a/greasemonkey/mtg plot reader view.js b/greasemonkey/mtg plot reader view.js new file mode 100644 index 0000000..5a46e1d --- /dev/null +++ b/greasemonkey/mtg plot reader view.js @@ -0,0 +1,44 @@ +// ==UserScript== +// @name mtg plot reader view +// @version 1 +// @grant none +// @namespace adamrgrey.com +// @license MIT +// @description prepare an mtg article for printing to pdf - like reader view, but save in one file, and keep images +// @include /^https?://magic.wizards.com\/en\/news\/magic-story/ + +// ==/UserScript== + + + +setTimeout(() => { + purgeSiblingsUp(document.querySelector("article")); +}, 2000); + +function purgeSiblingsUp(targetElement){ + console.log("purging siblings of", targetElement); + let parent = targetElement.parentElement; + if(parent == null || parent === targetElement){ + console.log("lol j/k, at the top"); + return; + } + if(targetElement.nodeName == "BODY"){ + console.log("lol j/k, found the body"); + return; + } + console.log(parent); + var children = targetElement.parentElement.children; + if(children.length > 1){ + let del = []; + for (let i = 0; i < children.length; i++) { + if(children[i] !== targetElement){ + del.push(children[i]); + } + } + console.log(del.length + " targets") + for (let i = 0; i < del.length; i++) { + del[i].remove(); + } + } + purgeSiblingsUp(parent); +} \ No newline at end of file