Electrek Auto Expand (with Custom Confirmation)

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

  1. // ==UserScript==
  2. // @name Electrek Auto Expand (with Custom Confirmation)
  3. // @namespace http://electrek.co/
  4. // @description Scrolls, highlights, and prompts before clicking expand links on Electrek using a custom modal.
  5. // @match https://electrek.co/*
  6. // @grant none
  7. // @version 0.0.1.20250302123600
  8. // ==/UserScript==
  9.  
  10. let clickCount = 0;
  11. const clickedElements = new Set();
  12.  
  13. const activateExpand = () => {
  14. // Get all candidate links
  15. const links = document.querySelectorAll('.more-link .open:not(.close)');
  16. links.forEach(link => {
  17. if (clickCount >= 2 || clickedElements.has(link)) return;
  18. if (link.textContent.trim() === 'Expand') {
  19. const anchor = link.closest('a');
  20. // Mark element as processed
  21. clickedElements.add(link);
  22. // Visual feedback with different colors
  23. anchor.style.outline = clickCount === 0 ? '#ff0000 solid 3px' : '#00ff00 solid 3px';
  24. // Scroll into view without animation
  25. anchor.scrollIntoView({behavior: 'auto', block: 'center'});
  26. // Disable scroll manipulation
  27. window.scrollTo = Element.prototype.scrollIntoView = function(){};
  28. // Increment counter before click
  29. clickCount++;
  30. // Trigger click with slight delay between clicks
  31. setTimeout(() => {
  32. anchor.click();
  33. // Disconnect after second click
  34. if (clickCount === 2) {
  35. observer.disconnect();
  36. console.log('Stopped after clicking 2 elements');
  37. }
  38. }, clickCount * 300); // Add 300ms delay between clicks
  39. }
  40. });
  41. };
  42.  
  43. const observer = new MutationObserver(activateExpand);
  44. observer.observe(document.body, {childList: true, subtree: true});
  45. activateExpand();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址