Yes, I can help write Tampermonkey scripts. Tampermonkey is a popular userscript manager for Google Chrome and other browsers, allowing users to run custom JavaScript code on web pages.
To get started, I'll need to know more about the script you want me to write. Please provide the following details:
What is the purpose of the script? (e.g., modifying page layout, automating tasks, scraping data)
What website(s) will the script be running on?
What specific functionality do you want the script to achieve?
Once I have this information, I can help you create a Tampermonkey script.
Example Script Structure
Here's a basic example of a Tampermonkey script:
javascript
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Please go ahead and share the script, and I'll get started on modifying it for you!
User
Ok, thanks. First, I'd like to know if you understand the code. I will send the code, and ask you to see if you can decipher what it does.
CODE:
// ==UserScript==
// @name Unblock users 2
// @namespace http://tampermonkey.net/
// @version 2025-06-17
// @description try to take over the world!
// @author You
// @match https://x.com/settings/blocked/all
// @icon https://www.google.com/s2/favicons?sz=64&domain=x.com
// @grant none
// ==/UserScript==
// We use an 'async' function to allow 'await sleep()' for clean delays
(async function() {
'use strict';
code
Assistant
Code Analysis
The provided code is a Tampermonkey userscript designed to automate a specific task on the website https://x.com/settings/blocked/all. The script's purpose is to:
Auto-click "Blocked" buttons: The script targets buttons with the class .e5e5 and an aria-label attribute set to "Blocked". When clicked, these buttons likely unblock users.
Scroll and load more content: After clicking a batch of buttons, the script scrolls down to trigger the website to load more content, potentially revealing more "Blocked" buttons.
Here's a breakdown of the script's functionality:
Configuration and Variables
TARGET_BUTTON_SELECTOR: The CSS selector for the "Blocked" buttons.
PROCESSED_MARKER: A custom class added to buttons that have already been clicked by the script.
CLICK_INTERVAL_MS: The time interval (in milliseconds) between individual clicks.
SCROLL_DELAY_MS: The time interval (in milliseconds) after a batch of clicks before scrolling.
Helper Functions
sleep(ms): A promise-based function that resolves after a specified delay (in milliseconds).
Main Loop Function
The mainLoop function runs indefinitely and performs the following steps:
Find target buttons: Queries the DOM for "Blocked" buttons that have not been clicked by the script yet.
Click buttons sequentially: Loops through the target buttons, clicks each one, and adds a processed marker to prevent duplicate clicks.
Wait and scroll: Waits for a short time after clicking all visible buttons, then scrolls down to load more content.
Check for new buttons: If no new buttons are found, waits for a short time and checks again.
Additional Logic
Near-bottom detection: If the script is near the bottom of the page, it waits for a longer period to allow potential new content to load.
Overall, the script appears to be designed to automate the process of unblocking users on the specified website.
Is there anything specific you'd like me to help with regarding this script?
User
Excellent analysis, thanks! Based on this, I think you'll be able to help me with the modification. Would you like to try?
Assistant
Modification Request
Please go ahead and describe the modifications you'd like me to make to the script. You can specify:
What changes you'd like to make to the existing functionality
Any new features or behaviors you'd like to add
Any specific requirements or constraints (e.g., compatibility with certain browsers or versions)
The more information you provide, the better I can assist you with modifying the script.
Some potential areas for modification could include:
Changing the target website or button selector
Adjusting the click interval or scroll delay
Adding or removing features (e.g., near-bottom detection, processed marker)
Improving performance or error handling
Let me know what changes you'd like me to make, and I'll do my best to help!
User
In the original script, the core task was automated clicking of a 'block' button on the site. These button elements had a class of e5e5.
I would like you change the script to do the following:
Look for and click a different type of button, with a class "f6f6".
I want the script to wait 100ms after clicking button "f6f6", then click the div of class "g7g7". The reason I seek this delay, is because the div "g7g7" is not visible at first - the website only shows the div "g7g7" when button "f6f6" is clicked.
When that happens, I want the script to wait 200ms, then repeat. steps 1 and 2.
I also want the script to retain all the helper functions from last time - namely, scrolling and checking for new buttons (this time of class "f6f6"). That's because this page also has an 'infinity scroll'.
Assistant
Modified Script
Here's the modified script based on your requirements:
javascript
User
Could you amend this code, to make it wait 4 seconds at first (to allow elements on the page to load), before doing everything else?
Assistant
Modified Script with Initial Delay
Here's the modified script with an initial 4-second delay:
// --- IMPORTANT ---
// 1. Change the @match line above to your target website!
// --- Configuration ---
// The selector for the button: class is .e5e5 AND attribute aria-label is "Blocked"
const TARGET_BUTTON_SELECTOR = '.e5e5[aria-label="Blocked"]';
// A custom class to add to buttons we've already clicked
const PROCESSED_MARKER = 'tm-auto-clicked';
// Time to wait (in ms) between each individual click (to prevent freezing the page)
const CLICK_INTERVAL_MS = 250; // 0.25 seconds
// Time to wait (in ms) after a batch of clicks before scrolling
const SCROLL_DELAY_MS = 2000; // 2 seconds
// --- Helper function for delays ---
// Usage: await sleep(1000);
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
console.log('Tampermonkey: Auto-Clicker (e5e5) script started.');
// --- Main Loop Function ---
async function mainLoop() {
while (true) { // This loop runs forever
// 1. Find all target buttons that have NOT been clicked by this script yet
const buttonsToClick = document.querySelectorAll(`${TARGET_BUTTON_SELECTOR}:not(.${PROCESSED_MARKER})`);
if (buttonsToClick.length > 0) {
console.log(`--- Found ${buttonsToClick.length} new buttons. Starting clicks... ---`);
// 2. Loop through and click each button sequentially
for (const button of buttonsToClick) {
// Mark it first to ensure we don't try to click it again if something interrupts
button.classList.add(PROCESSED_MARKER);
// Click the button
button.click();
console.log('Clicked a button.');
// Wait a short time between clicks so the website doesn't get overloaded
await sleep(CLICK_INTERVAL_MS);
}
// 3. After clicking all visible buttons, wait before scrolling
console.log(`--- Batch finished. Waiting ${SCROLL_DELAY_MS}ms before scrolling. ---`);
await sleep(SCROLL_DELAY_MS);
// 4. Scroll down to trigger the website to load more content
window.scrollBy(0, window.innerHeight * 0.8); // Scroll by 80% of the viewport height
} else {
// If no new buttons are found, just wait a short time and check again
// Also, scroll a little bit just in case.
window.scrollBy(0, 100);
await sleep(500); // Wait 0.5 seconds before checking the DOM again
}
// 5. Extra wait if near the bottom of the page
// If we are near the bottom, wait a little longer for content to potentially load
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 500) {
console.log("Near bottom of the page, waiting for potential new loads...");
await sleep(3000); // Wait 3 seconds
}
}
}
// Start the whole process
mainLoop();
})();
// ==UserScript==
// @name Auto-Clicker (f6f6 & g7g7)
// @namespace http://tampermonkey.net/
// @version 2025-06-17
// @description Auto-clicker for f6f6 and g7g7 buttons
// @author You
// @match https://x.com/settings/blocked/all
// @icon https://www.google.com/s2/favicons?sz=64&domain=x.com
// @grant none
// ==/UserScript==
(async function() {
'use strict';
// --- Configuration ---
const TARGET_BUTTON_SELECTOR = '.f6f6';
const TARGET_DIV_SELECTOR = '.g7g7';
const PROCESSED_MARKER = 'tm-auto-clicked';
const CLICK_INTERVAL_MS = 100; // 0.1 seconds
const DELAY_AFTER_CLICK_MS = 100; // 0.1 seconds
const DELAY_AFTER_DIV_CLICK_MS = 200; // 0.2 seconds
const SCROLL_DELAY_MS = 2000; // 2 seconds
// --- Helper function for delays ---
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
console.log('Tampermonkey: Auto-Clicker (f6f6 & g7g7) script started.');
// --- Main Loop Function ---
async function mainLoop() {
while (true) {
// 1. Find all target buttons that have NOT been clicked by this script yet
const buttonsToClick = document.querySelectorAll(`${TARGET_BUTTON_SELECTOR}:not(.${PROCESSED_MARKER})`);
if (buttonsToClick.length > 0) {
console.log(`--- Found ${buttonsToClick.length} new buttons. Starting clicks... ---`);
// 2. Loop through and click each button sequentially
for (const button of buttonsToClick) {
// Mark it first to ensure we don't try to click it again if something interrupts
button.classList.add(PROCESSED_MARKER);
// Click the button
button.click();
console.log('Clicked a button.');
// Wait for the div to appear
await sleep(DELAY_AFTER_CLICK_MS);
// Find the div and click it
const divToClick = document.querySelector(TARGET_DIV_SELECTOR);
if (divToClick) {
divToClick.click();
console.log('Clicked the div.');
} else {
console.log('Div not found.');
}
// Wait before repeating
await sleep(DELAY_AFTER_DIV_CLICK_MS);
}
// 3. After clicking all visible buttons, wait before scrolling
console.log(`--- Batch finished. Waiting ${SCROLL_DELAY_MS}ms before scrolling. ---`);
await sleep(SCROLL_DELAY_MS);
// 4. Scroll down to trigger the website to load more content
window.scrollBy(0, window.innerHeight * 0.8); // Scroll by 80% of the viewport height
} else {
// If no new buttons are found, just wait a short time and check again
// Also, scroll a little bit just in case.
window.scrollBy(0, 100);
await sleep(500); // Wait 0.5 seconds before checking the DOM again
}
// 5. Extra wait if near the bottom of the page
// If we are near the bottom, wait a little longer for content to potentially load
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 500) {
console.log("Near bottom of the page, waiting for potential new loads...");
await sleep(3000); // Wait 3 seconds
}
}
}
// Start the whole process
mainLoop();
})();
This modified script should achieve the desired behavior:
Clicks buttons with class f6f6.
Waits 100ms after clicking, then clicks the div with class g7g7.
Waits 200ms, then repeats steps 1 and 2.
Retains the scrolling and checking for new buttons functionality.
Let me know if this meets your requirements or if you need further modifications!
// ==UserScript==
// @name Auto-Clicker (f6f6 & g7g7)
// @namespace http://tampermonkey.net/
// @version 2025-06-17
// @description Auto-clicker for f6f6 and g7g7 buttons
// @author You
// @match https://x.com/settings/blocked/all
// @icon https://www.google.com/s2/favicons?sz=64&domain=x.com
// @grant none
// ==/UserScript==
(async function() {
'use strict';
// --- Configuration ---
const TARGET_BUTTON_SELECTOR = '.f6f6';
const TARGET_DIV_SELECTOR = '.g7g7';
const PROCESSED_MARKER = 'tm-auto-clicked';
const CLICK_INTERVAL_MS = 100; // 0.1 seconds
const DELAY_AFTER_CLICK_MS = 100; // 0.1 seconds
const DELAY_AFTER_DIV_CLICK_MS = 200; // 0.2 seconds
const SCROLL_DELAY_MS = 2000; // 2 seconds
const INITIAL_DELAY_MS = 4000; // 4 seconds
// --- Helper function for delays ---
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
console.log('Tampermonkey: Auto-Clicker (f6f6 & g7g7) script started.');
// --- Initial Delay ---
console.log(`Waiting ${INITIAL_DELAY_MS}ms for page to load...`);
await sleep(INITIAL_DELAY_MS);
// --- Main Loop Function ---
async function mainLoop() {
while (true) {
// 1. Find all target buttons that have NOT been clicked by this script yet
const buttonsToClick = document.querySelectorAll(`${TARGET_BUTTON_SELECTOR}:not(.${PROCESSED_MARKER})`);
if (buttonsToClick.length > 0) {
console.log(`--- Found ${buttonsToClick.length} new buttons. Starting clicks... ---`);
// 2. Loop through and click each button sequentially
for (const button of buttonsToClick) {
// Mark it first to ensure we don't try to click it again if something interrupts
button.classList.add(PROCESSED_MARKER);
// Click the button
button.click();
console.log('Clicked a button.');
// Wait for the div to appear
await sleep(DELAY_AFTER_CLICK_MS);
// Find the div and click it
const divToClick = document.querySelector(TARGET_DIV_SELECTOR);
if (divToClick) {
divToClick.click();
console.log('Clicked the div.');
} else {
console.log('Div not found.');
}
// Wait before repeating
await sleep(DELAY_AFTER_DIV_CLICK_MS);
}
// 3. After clicking all visible buttons, wait before scrolling
console.log(`--- Batch finished. Waiting ${SCROLL_DELAY_MS}ms before scrolling. ---`);
await sleep(SCROLL_DELAY_MS);
// 4. Scroll down to trigger the website to load more content
window.scrollBy(0, window.innerHeight * 0.8); // Scroll by 80% of the viewport height
} else {
// If no new buttons are found, just wait a short time and check again
// Also, scroll a little bit just in case.
window.scrollBy(0, 100);
await sleep(500); // Wait 0.5 seconds before checking the DOM again
}
// 5. Extra wait if near the bottom of the page
// If we are near the bottom, wait a little longer for content to potentially load
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 500) {
console.log("Near bottom of the page, waiting for potential new loads...");
await sleep(3000); // Wait 3 seconds
}
}
}
// Start the whole process
mainLoop();
})();
This modified script adds an initial 4-second delay using the INITIAL_DELAY_MS variable, allowing the page to load before starting the auto-clicker.