LazyAutoScrollerJS

06/06/2023 00:48:42

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        LazyAutoScrollerJS
// @namespace   https://github.com/Grrraou/lazyAutoScrollerJS
// @match        https://9gag.com/*
// @license MIT
// @grant       none
// @version     1.0
// @author      -
// @description 06/06/2023 00:48:42
// ==/UserScript==
// Create the start and stop buttons
const autoscrollButton = document.createElement('button');
autoscrollButton.innerHTML = '►'; // Play icon
autoscrollButton.style.position = 'fixed';
autoscrollButton.style.bottom = '20px';
autoscrollButton.style.right = '20px';
autoscrollButton.style.width = '30px';
autoscrollButton.style.height = '30px';
autoscrollButton.style.backgroundColor = 'green';
autoscrollButton.style.borderRadius = '50%';
autoscrollButton.style.display = 'flex';
autoscrollButton.style.justifyContent = 'center';
autoscrollButton.style.alignItems = 'center';
autoscrollButton.style.fontSize = '14px';
autoscrollButton.style.color = 'white';
autoscrollButton.style.cursor = 'pointer';

// Create the speed control slider
const speedSlider = document.createElement('input');
speedSlider.type = 'range';
speedSlider.min = '1';
speedSlider.max = '10';
speedSlider.value = '5';
speedSlider.style.width = '200px';
speedSlider.style.position = 'fixed';
speedSlider.style.bottom = '70px';
speedSlider.style.right = '20px';

// Select the element to be scrolled
const elementToScroll = document.documentElement; // Change this to the desired element

// Set the initial scroll speed and interval in milliseconds
let scrollSpeed = parseInt(speedSlider.value);
const scrollInterval = 10; // Adjust this value to change the scroll interval

let isScrolling = false;
let scrollIntervalId;

// Function to start or stop autoscrolling
function toggleAutoscroll() {
  if (isScrolling) {
    clearInterval(scrollIntervalId);
    autoscrollButton.style.backgroundColor = 'green';
    autoscrollButton.innerHTML = '►'; // Play icon
  } else {
    scrollSpeed = parseInt(speedSlider.value);
    scrollIntervalId = setInterval(autoscroll, scrollInterval);
    autoscrollButton.style.backgroundColor = 'red';
    autoscrollButton.innerHTML = '◼'; // Stop icon
  }
  isScrolling = !isScrolling;
}

// Function to scroll the element
function autoscroll() {
  elementToScroll.scrollBy(0, scrollSpeed); // Scrolls vertically, adjust the X and Y values for horizontal scrolling
}

// Add click event listener to the autoscroll button
autoscrollButton.addEventListener('click', toggleAutoscroll);

// Append the autoscroll button and speed control slider to the document body
document.body.appendChild(autoscrollButton);
document.body.appendChild(speedSlider);