/r/GreaseMonkey
If you make a Grease Monkey script for Reddit, post a link here.
/r/GreaseMonkey
Hi, my current script almost is done, but on the last page I need, I absolutely need the referrer. Setting it to empty forwards me to the main page. Any idea? (And yes, I verified, that the statement "referrer ?? url" does indeed work correctly via console.log. Dev tools just show no referrer header at all. I know this issue was known in 2007 already. But was there never a fix for this? Would really suck if this cannot be done.
Fraction of my function:
GM.xmlHttpRequest(
{
"credentials": "include",
"headers": headers ??
{
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/69.0 - Custom",
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8",
},
"url": url,
"origin": url,
"referrer": referrer ?? url,
"data": body,
"method": method,
"mode": "cors",
onload: function(response)
I have this small script that updates each timestamp beside post (say x hours ago) with exact time for me to look at. https://greasyfork.org/en/scripts/519330-reddit-post-time-visible
The problem is for recent posts, whose timestamp is getting updated by Reddit continuously; although I have a mutation observer, it still fails to detect sometimes, so I am wondering if there is a better way to do it. like, probably blocking Reddit updates or tracking it efficiently to update?
I heard, that TamperMonkey include should support Regex...
But it is not working correctly.
// @include http[s]?:\/\/[\d\w]*.[\d\w]*\/?[\W\w]*
Before you say, that this pattern is extremely dangerous... I know. Just a test example.
But just why does it not work? Regexr matches the URLs I tested just fine. Are there some rules to be considered for such patterns?
Edit - solution was found by @_1Zen_ :
The solution is simple and obvious, if you come across this issue yourself:
// @include /http[s]?:\/\/[\d\w]*.[\d\w]*\/?[\W\w]*/
BUT PLEASE DO NOT USE THIS REGEX. It is pure danger.
Hey everyone!
I'm working on a project where I need to inject text into Google Docs in a way that mimics real human typing, including typing speed, random errors, and even fixing those errors in real-time. The goal is to make the process look as if the text was typed directly into the document, as opposed to pasted, by simulating a natural typing flow.
Here’s the basic functionality I’m looking for:
This is a Chrome extension, and it should work across all pages of Google Docs, including the standard editing view and the document URL with user-specific paths (e.g., https://docs.google.com/document/u/0/
).
I’m looking for someone who has experience with browser extensions (Chrome), JavaScript, and working with web page elements like contenteditable
areas or text nodes.
Let me know if you're interested or if you have any questions!
Thanks!
Hello, I wanted to share this somewhere on reddit so others could use it, I used to have a script that had this feature but ig it stopped working as it was part of a bigger script for reddit that broke over time or something and I was really annoyed that it was gone as it was something I used basically every time I opened reddit. So with a bit of help from ChatGPT to solve a few issues, I made a dedicated script to use the arrow keys to navigate hovered image galleries on reddit.
Enjoy: https://greasyfork.org/en/scripts/518645-reddit-image-gallery-arrow-navigation
Hello,
Is there a way to do something similar to https://www.reddit.com/r/shortcuts/s/KMCa8ZKdFo in Windows 11 Google Chrome? I have tamper monkey add-on but not sure if it’s the right add on to use? Basically I want to have like an add-on shortcut that I press and it acts the same as in OP’s example - Taking the URL and redirecting to one of the archive websites.
Thank you.
Hi, I'm pretty new to Monkey and adding navigation by arrow keys to my fav websites (smooth so far, great thing...), but on one I have no identifiable properties (id, class, rel etc.) apart from the linktext. So basically just <a>« prev</a> and <a>next »</a>, the href is just absolute pages eg. page123.html.
How can I access that for my .click()? Intention is something like this (I know its not working and possibly can't even be done within document.querySelector(), just to show what I want to do basically):
document.querySelector('a:has-text(/^« prev$/)').click();
Im just removing an element in my code.
Here it shows error from the page
in chrome console command this deletes my element.
Also if I change my code to document.body.remove(); this worked through tampermonkey on the chrome webpage and deletes everything which tells me the inject is connected and working with the url.
Any ideas how to get this running correctly? Seems like it would be some setting in tampermonkey.
https://imgur.com/a/tamper-monkey-xbox-wish-list-2xfvG8i Before and After images
// ==UserScript==
// @name Xbox Wishlist Sale Items Only
// @namespace http://tampermonkey.net/
// @version 1.9
// @description Display only sale items from Xbox wishlist, sorted by discount
// @match https://www.xbox.com/en-us/wishlist
// @icon https://www.google.com/s2/favicons?sz=64&domain=xbox.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
function getWishlistData() {
try {
const scriptTags = document.querySelectorAll('script');
for (const script of scriptTags) {
if (script.innerText.includes('window.__PRELOADED_STATE__')) {
const dataMatch = script.innerText.match(/window\.__PRELOADED_STATE__\s*=\s*(\{.*\})\s*;/);
if (dataMatch && dataMatch[1]) {
const wishlistData = JSON.parse(dataMatch[1]);
return Object.values(wishlistData.core2?.products?.productSummaries || {});
}
}
}
console.error("Wishlist data not found in the current HTML.");
return [];
} catch (error) {
console.error("Error parsing wishlist data:", error);
return [];
}
}
function injectCustomStyles() {
const styles = `
.WishlistPage-module__centerContainer___2dDfq { display: block !important; justify-content: initial !important; }
.wishlist-container { width: 80%; padding-top: 20px; margin-left: 2%; margin-right: 2%; }
.wishlist-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; padding: 16px; }
.custom-card { position: relative; width: 250px; height: 400px; background: #2a2a2a; border-radius: 10px; overflow: hidden; font-family: Arial, sans-serif; color: #fff; transition: box-shadow 0.3s ease; }
.custom-card img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; transition: transform 0.3s ease; }
.custom-card:hover img { transform: scale(1.05); box-shadow: 0px 0px 15px rgba(255, 255, 255, 0.5); }
.overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 10px; border-radius: 10px; }
.custom-card-title { text-align: center; text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black; font-size: 18px; font-weight: bold; }
.price-info { display: flex; justify-content: space-between; align-items: center; font-size: 14px; width: 100%; padding: 5px; background: rgba(25, 25, 25, 0.8); border-radius: 5px; }
.custom-card-price { color: #4CAF50; font-weight: bold; }
.custom-card-original-price { color: #888; text-decoration: line-through; }
.custom-card-discount { color: #FF5733; font-weight: bold; }
.custom-card-rating { color: #FFD700; font-size: 14px; text-align: right; }
`;
const styleSheet = document.createElement("style");
styleSheet.type = "text/css";
styleSheet.innerText = styles;
document.head.appendChild(styleSheet);
}
function clearOriginalWishlistItems() {
const originalItems = document.querySelectorAll('.WishlistProductItem-module__itemContainer___weUfG');
originalItems.forEach(item => item.remove());
}
function displayWishlistData(wishlistItems) {
clearOriginalWishlistItems();
const gridContainer = document.querySelector('.wishlist-grid');
gridContainer.innerHTML = '';
const filteredItems = wishlistItems
.filter(item => {
const salePrice = item.specificPrices?.purchaseable[0]?.listPrice || null;
const originalPrice = item.specificPrices?.purchaseable[0]?.msrp || null;
return salePrice && salePrice < originalPrice;
})
.sort((a, b) => {
const discountA = a.specificPrices?.purchaseable[0]?.discountPercentage || 0;
const discountB = b.specificPrices?.purchaseable[0]?.discountPercentage || 0;
return discountB - discountA;
});
filteredItems.forEach(item => {
const title = item.title || "Unknown Game";
const salePrice = item.specificPrices?.purchaseable[0]?.listPrice || null;
const originalPrice = item.specificPrices?.purchaseable[0]?.msrp || null;
const discountPercent = item.specificPrices?.purchaseable[0]?.discountPercentage || 0;
const skuID = item.specificPrices?.purchaseable[0]?.skuId || null;
const productID = item.productId;
const imageUrl = item.images?.poster?.url || "https://via.placeholder.com/250x320";
const rating = item.averageRating || 0;
const detailUrl = `https://www.xbox.com/en-US/games/store/${title.replace(/\s/g, '-').toLowerCase()}/${productID}/${skuID}`;
const card = document.createElement('div');
card.style.cursor = 'pointer';
card.onclick = () => window.open(detailUrl, '_blank');
card.className = 'custom-card';
const imgElement = document.createElement('img');
imgElement.src = imageUrl;
card.appendChild(imgElement);
const overlay = document.createElement('div');
overlay.className = 'overlay';
const titleElement = document.createElement('div');
titleElement.className = 'custom-card-title';
overlay.appendChild(titleElement);
const priceInfo = document.createElement('div');
priceInfo.className = 'price-info';
if (salePrice) {
const salePriceElement = document.createElement('span');
salePriceElement.className = 'custom-card-price';
salePriceElement.textContent = `$${salePrice.toFixed(2)}`;
priceInfo.appendChild(salePriceElement);
}
if (originalPrice && salePrice < originalPrice) {
const originalPriceElement = document.createElement('span');
originalPriceElement.className = 'custom-card-original-price';
originalPriceElement.textContent = `$${originalPrice.toFixed(2)}`;
priceInfo.appendChild(originalPriceElement);
const discountElement = document.createElement('span');
discountElement.className = 'custom-card-discount';
discountElement.textContent = `${Math.round(discountPercent, 2)}% OFF`;
priceInfo.appendChild(discountElement);
}
overlay.appendChild(priceInfo);
const ratingElement = document.createElement('span');
ratingElement.className = 'custom-card-rating';
ratingElement.textContent = `★ ${rating.toFixed(1)}`;
priceInfo.appendChild(ratingElement);
card.appendChild(overlay);
gridContainer.appendChild(card);
});
}
function initialize() {
const wishlistContainer = document.querySelector('.WishlistPage-module__wishListForm___p6wOx');
if (!wishlistContainer) {
console.log("Wishlist container not found.");
return;
}
wishlistContainer.classList.add('wishlist-container');
const gridContainer = document.createElement('div');
gridContainer.className = 'wishlist-grid';
wishlistContainer.appendChild(gridContainer);
const wishlistData = getWishlistData();
displayWishlistData(wishlistData);
}
window.addEventListener('load', () => {
injectCustomStyles();
initialize();
});
})();
Is there a script to disable the ESC key when browsing reddit?
When browsing reddit, if I press the ESC key, the browser will go back to the previous page. I want to disable this behaviors. Because I am using a VIM plugin, it uses the ESC key a lot. When I accident to press the ESC, the browser will go back, it is really anointing.
Anyone have any useless/fun script ideas?
like the following (that i've already created + posted):
Replace All Text With "?" (all websites)
Random Insult Generator (all websites)
The Useless Web Button (all websites)
Random Scrollbar Jumper (all websites)
Random Browser Zoom (all websites)
Browser Tab Name Changed To " " (all websites)
Feel free to check out UnknownQwertyz on greasyfork.org for more info!
LOOKING FOR A PARTNER!!
I took inspo from AND used to work with someone who is named "The Usless Things Series: ???" and i want to continue to bring useless and fun scripts to people because they are fun to make and test, I no longer have a partner, but i want to continue to make these scripts because a very small community of people seem to have fun with trying my scripts out, so i need ideas OR someone who would like to help in the making of any future scripts.
Im trying to write a script that will change the number 7.00 from this line of code, to 12.00.
<span class="data" tabindex="0">7.00</span>
however i am completely lost and nothing seems to be working for me.
I've had anxiety with all this US election talk so I made a script to remove post that contains certain keywords in there title.
You can customize, the keywords array to your need.
// ==UserScript==
// @name Reddit Keyword Filter
// @namespace http://tampermonkey.net/
// @version 1.1
// @description Remove Reddit articles containing specified keywords
// @author Iko
// @match https://*.reddit.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=reddit.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Define the list of keywords to filter
const keywords = ['trump', 'election', 'harris', 'kamala','gop','democrat','republican','project 2025']; // Add any keywords you want to detect
const checkedClass = 'checked-by-script'; // Class to mark articles that have been checked
// Function to check and remove articles containing keywords
function filterArticles() {
document.querySelectorAll(`article:not(.${checkedClass})`).forEach((article) => {
const textContent = article.querySelector('faceplate-screen-reader-content')?.innerText.toLowerCase();
if (textContent && keywords.some(keyword => textContent.includes(keyword))) {
article.remove();
}
// Mark article as checked by adding the class
article.classList.add(checkedClass);
});
}
// Run the filter function initially to catch already loaded articles
filterArticles();
// Set up a MutationObserver to detect dynamically added articles
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'childList') {
filterArticles();
}
});
});
// Start observing the document body for added/removed nodes
observer.observe(document.body, { childList: true, subtree: true });
})();
Does TM/GM not work on finance.yahoo.com or am I doing something wrong? I have working scripts on other sites, but for some reason I can't get the simplest thing to even start on https://finance.yahoo.com/quotes/INTC/view/v1
edit: TamperMonkey v5.3.2, Brave
Simple script to do a log to console, eight second delay:
// ==UserScript==
// @name INTC trade update
// @namespace http://tampermonkey.net/
// @version 2024-11-06
// @description Update me on position of INTC trade
// @author You
// @match https://finance.yahoo.com/quotes/INTC/view/v1
// @icon https://www.google.com/s2/favicons?sz=64&domain=yahoo.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
window.addEventListener("load",
function(event) {
console.log("Loaded");
setTimeout(showUpdate, 8000);
}
);
function showUpdate() {
console.log("Running...");
}
})();
Like the title says.
too lazy to log into my greasyfork account to upload atm, so here you all go. I had necro-commented this into an old-ish post yesterday, but figure this deserves a post of its own.
// ==UserScript==
// @name Remove Reddit Blurs
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Remove spoiler tagging
// @author pfn0
// @match https://*.reddit.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=reddit.com
// @license MIT
// @grant none
// ==/UserScript==
(function() {
'use strict';
function handleFiltering() {
removeSpoilerTags();
}
function removeSpoilerTags() {
Array.prototype.forEach.call(document.getElementsByTagName("shreddit-blurred-container"), x => { x.blurred = false });
Array.prototype.forEach.call(document.getElementsByTagName("shreddit-spoiler"), x => { x.revealed = true });
}
handleFiltering();
const config = { attributes: true, childList: true, subtree: true };
const observer = new MutationObserver((x,y) => handleFiltering());
observer.observe(document, config);
})();
so i got this website where i have to open like 10 pages of their social media and keep open by 10 seconds one by one, and its so annoying if anyone can do kinda of "automation" or even bypass i would be happy. there is it: https://www.projectcheats.com btw u have like to press on Recharge or Recarga idk what the default language is. I appreciate any time taken for this code
I want a script for Firefox on Android to take input to the address bar, and if it starts with "go/" take me to http://go/%s. I had claude.ai write a script that doesn't seem to work. Firefox Android will take whatever that doesn't start with http and make it a web search. Sometimes if I've been to http://go/foo in the past, it will suggest it again. But if it's somewhere I haven't been before it makes it a web search instead of suggesting going directly to http://go/%s
Here's the script claude wrote:
// ==UserScript==
// @name Go Links Handler
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Redirects go/ URLs to internal links
// @author You
// @match *://go/*
// @match https://*/*
// @match http://*/*
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
// Function to check if URL matches go/ pattern and redirect
function handleGoLink() {
// Get current URL
const currentUrl = window.location.href;
// Check for go/ pattern in different formats
const goUrlPattern = /^(?:http:\/\/|https:\/\/)?(?:www\.)?(?:google\.com\/search\?q=)?(?:go\/)(.+)/i;
const match = currentUrl.match(goUrlPattern);
// Also check if it's a search query containing go/
const searchPattern = /(?:^|\s)go\/(\S+)(?:\s|$)/i;
const searchMatch = decodeURIComponent(currentUrl).match(searchPattern);
if (match || searchMatch) {
// Get the path after "go/"
const path = (match ? match[1] : searchMatch[1]);
// Remove any trailing parameters or hash
const cleanPath = path.split(/[#?]/)[0];
// Construct the new URL
const newUrl = `http://go/${cleanPath}`;
// Only redirect if we're not already at the destination
if (currentUrl !== newUrl) {
window.location.replace(newUrl);
}
}
}
// Run immediately
handleGoLink();
})();
I noticed yesterday when I was trying to use Tom Saleeba's custom YouTube speeds TM script in Chrome that the script was not (working/loading/running?).
I wanted to make a post in case anyone else is having trouble, or is this something on my end?
Any remedy for this?
is it possible for someone to create a script that can bypass the page browsing limit of 1000 pages on https://danbooru.donmai.us/ ? for 2 years now danbooru hasn't been able to let people sign up for Gold membership
Hey guys , so i am still new to using tamper monkey , i have used it to download like 2 collections on nexusmods and it was working good , now for some reason when i try to download a collection it asks me for a place to download for every mod , so when i tried to download a collection with 500 mods i needed to press save for all the 500 , does anyone know the reason ? thanks for advance
Hi all,
I enjoy using old reddit over new reddit - I've gone ahead blocked the home-feed with a different extension (Undistracted). I know SocialFocus (another distraction blocking extension) blocks subreddit feeds for new-reddit. Is there some tampermonkey script that does this but for old-reddit?
Simple question, i want to know, please. I want to became a young developer and i want to code scripts
im currently doing an online school called K12 and i have hundereds of assignments and i want to figure out how to auto do all my assignments please help🙏🙏
I am on a page, where I want to redirect myself to a certain stream. The stream is the source attribute of an iframe inside an iframe. So far so good. My tampermonkey script correctly detects the location and for debugging purpose I logged it successfully. Now trying to redirect, it appears, that my query on this Iframe has shifted the document reference to the innermost iframe. So the location.replace(stream) actually loads the stream again in the iframe in the iframe. You want to know, what the solution to this issue is?
window.top.document.location.replace(stream);
I only figured it out, because suddenly the debug console of the browser was not able to document.querySelector
the iframe anymore. It was returning null
. But window.top.document.querySelector("iframe")
found it again. What is going on here? Since when does the definition of "document
" suddenly change completely and can only be referenced by window.top.document
? HUH?
Untill now I did not even know of window.top.document or even window.top. Explain this ridiculessnes to me!
Hello there.
I looked online for a script but sadly found nothing. I figure it should be possible because I currently use scripts that does similar things, though I know close to nothing about code, so maybe I’m mistaking. ^^
I’m tired of Amazon selecting the subscription option by default when buying an item… I’d love to automatize the switch to the « buy one » option. ( I tried asking GPT, which was friendly helping, but for a noob like me, an epistolary code course was a hell of a useless ride lol )
Here’s a picture about the devil thing, found on another Reddit. ( I use French Amazon though. )
If it’s an easy thing to do, I’m all ears !
Regards.
I have written some TamperMonkey scripts on Brave, and would like to back them up with my regular backups. Where are they stored? I tried to find them in Windows/users/<myusername>/AppData with no success.