Enhanced Scrolling

Enhance your browsing experience with a customized scrollbar style on any website.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name           Enhanced Scrolling
// @namespace      https://twitter.com/simeonleni
// @description    Enhance your browsing experience with a customized scrollbar style on any website.
// @run-at         document-end
// @match          *://*/*
// @grant          GM_addStyle
// @version        1.0
// ==/UserScript==

(function() {

  var scrollTop = 0;
  var backgroundColor = window.getComputedStyle(document.body).getPropertyValue('background-color');

  var scrollbar = `
    ::-webkit-scrollbar {
      width: 10px;
      border-radius: 0px;
    }

    ::-webkit-scrollbar-track {
      background-color: transparent;

    }

    ::-webkit-scrollbar-thumb {
      border-radius: 6px;
      background-color: #72727278;
      border: 4px solid ${backgroundColor};
    }

     ::-webkit-scrollbar-thumb:hover {
      border: 3px solid ${backgroundColor};
      background-color: #727272d1:
    }

    ::-webkit-scrollbar-corner {
      background-color: #f5f5f5;
    }
  `;


  function handleMouseDown(event) {
    if (event.clientX > window.innerWidth - 200) { // Adjust the drag area width as needed
      event.preventDefault(); // Prevent text selection
      event.stopPropagation(); // Prevent event bubbling
      scrollTop = event.clientY;
      document.addEventListener('mousemove', handleMouseMove);
      document.addEventListener('mouseup', handleMouseUp);
      document.documentElement.style.setProperty('--scrollbar-opacity', '1'); // Set the scrollbar opacity to 1 (fully opaque)
    }
  }

  // Event listener for mouse move event while dragging
  function handleMouseMove(event) {
    var deltaY = event.clientY - scrollTop;
    window.scrollBy(0, deltaY);
    scrollTop = event.clientY;
  }

  // Event listener for mouse up event
  function handleMouseUp() {
    document.removeEventListener('mousemove', handleMouseMove);
    document.removeEventListener('mouseup', handleMouseUp);
    document.documentElement.style.setProperty('--scrollbar-opacity', '0'); // Set the scrollbar opacity to 0 (fully transparent)
  }

  // Event listener for wheel event to enable mouse scroll
  function handleWheel(event) {
    window.scrollBy(0, event.deltaY);
    event.preventDefault(); // Prevent default scroll behavior
  }

  // Add event listeners
  document.addEventListener('mousedown', handleMouseDown);
  document.addEventListener('wheel', handleWheel);

  GM_addStyle(scrollbar);
})();