most of my current greasemonkey scripts

This commit is contained in:
adam 2023-03-07 10:21:15 -05:00
parent a32df404a6
commit e53b138cce
6 changed files with 266 additions and 0 deletions

110
greasemonkey/725984.js Normal file
View File

@ -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);

View File

@ -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 = `
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="32px" height="32px" id="RSSicon" viewBox="0 0 256 256">
<defs>
<linearGradient x1="0.085" y1="0.085" x2="0.915" y2="0.915" id="RSSg">
<stop offset="0.0" stop-color="#E3702D"/><stop offset="0.1071" stop-color="#EA7D31"/>
<stop offset="0.3503" stop-color="#F69537"/><stop offset="0.5" stop-color="#FB9E3A"/>
<stop offset="0.7016" stop-color="#EA7C31"/><stop offset="0.8866" stop-color="#DE642B"/>
<stop offset="1.0" stop-color="#D95B29"/>
</linearGradient>
</defs>
<rect width="256" height="256" rx="55" ry="55" x="0" y="0" fill="#CC5D15"/>
<rect width="246" height="246" rx="50" ry="50" x="5" y="5" fill="#F49C52"/>
<rect width="236" height="236" rx="47" ry="47" x="10" y="10" fill="url(#RSSg)"/>
<circle cx="68" cy="189" r="24" fill="#FFF"/>
<path d="M160 213h-34a82 82 0 0 0 -82 -82v-34a116 116 0 0 1 116 116z" fill="#FFF"/>
<path d="M184 213A140 140 0 0 0 44 73 V 38a175 175 0 0 1 175 175z" fill="#FFF"/>
</svg>
`.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);

View File

@ -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();

View File

@ -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);

View File

@ -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);

View File

@ -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);
}