🏠 返回首頁 

Greasy Fork is available in English.

Electrek Auto Expand (with Custom Confirmation)

Scrolls, highlights, and prompts before clicking expand links on Electrek using a custom modal.

// ==UserScript==
// @name         Electrek Auto Expand (with Custom Confirmation)
// @namespace    http://electrek.co/
// @description  Scrolls, highlights, and prompts before clicking expand links on Electrek using a custom modal.
// @match        https://electrek.co/*
// @grant        none
// @version 0.0.1.20250302123600
// ==/UserScript==
let clickCount = 0;
const clickedElements = new Set();
const activateExpand = () => {
// Get all candidate links
const links = document.querySelectorAll('.more-link .open:not(.close)');
links.forEach(link => {
if (clickCount >= 2 || clickedElements.has(link)) return;
if (link.textContent.trim() === 'Expand') {
const anchor = link.closest('a');
// Mark element as processed
clickedElements.add(link);
// Visual feedback with different colors
anchor.style.outline = clickCount === 0 ? '#ff0000 solid 3px' : '#00ff00 solid 3px';
// Scroll into view without animation
anchor.scrollIntoView({behavior: 'auto', block: 'center'});
// Disable scroll manipulation
window.scrollTo = Element.prototype.scrollIntoView = function(){};
// Increment counter before click
clickCount++;
// Trigger click with slight delay between clicks
setTimeout(() => {
anchor.click();
// Disconnect after second click
if (clickCount === 2) {
observer.disconnect();
console.log('Stopped after clicking 2 elements');
}
}, clickCount * 300); // Add 300ms delay between clicks
}
});
};
const observer = new MutationObserver(activateExpand);
observer.observe(document.body, {childList: true, subtree: true});
activateExpand();