Auto-Scroller

Auto-Scroller made by AI, works for both mobile and desktop.

目前為 2025-07-03 提交的版本,檢視 最新版本

// ==UserScript==
// @name        Auto-Scroller
// @match       *://*/*
// @license     MIT
// @version     1.01
// @description Auto-Scroller made by AI, works for both mobile and desktop.
// @grant       none
// @namespace https://greasyfork.org/users/1491313
// ==/UserScript==

(function(){
  'use strict';

  const SPEED       = 1;    // pixels per tick
  const INTERVAL_MS = 16;   // ms between ticks (~60fps)
  let ticker = null;

  function play(){
    if (!ticker) {
      ticker = setInterval(() => window.scrollBy(0, SPEED), INTERVAL_MS);
    }
  }

  function pause(){
    if (ticker) {
      clearInterval(ticker);
      ticker = null;
    }
  }

  // build controls
  const container = document.createElement('div');
  Object.assign(container.style, {
    position:   'fixed',
    bottom:     '20px',
    right:      '20px',
    display:    'flex',
    gap:        '6px',
    zIndex:     999999
  });

  function makeButton(symbol, handler){
    const btn = document.createElement('button');
    btn.textContent = symbol;
    Object.assign(btn.style, {
      padding:       '8px 12px',
      fontSize:      '18px',
      background:    'rgba(0,0,0,0.6)',
      color:         '#fff',
      border:        'none',
      borderRadius:  '6px',
      cursor:        'pointer'
    });
    btn.addEventListener('click', handler);
    return btn;
  }

  const playBtn  = makeButton('▶️', play);
  const pauseBtn = makeButton('⏸️', pause);
  container.append(playBtn, pauseBtn);
  document.body.appendChild(container);
})();