Return Scrollable

Enable scroll functionality after blocking pop-ups on certain sites.

Stan na 12-10-2024. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Return Scrollable
// @namespace    https://github.com/cilxe/JavaScriptProjects
// @version      0.1
// @description  Enable scroll functionality after blocking pop-ups on certain sites.
// @author       cilxe
// @match        *://*/*
// @icon         None
// @grant        GM_registerMenuCommand
// @grant        GM_setValue
// @grant        GM_getValue
// @run-at       document-body
// @license      MIT
// ==/UserScript==

(() => {
  const css = document.createElement('style');
  css.innerText += 'body { overflow: auto !important; }';

  // Function to append the CSS to the document head
  function appendCSS() {
    document.head.append(css);
    console.log('CSS applied: body { overflow: auto !important; }');
  }

  // Get stored sites from GM_getValue
  // eslint-disable-next-line no-undef
  const sites = GM_getValue('scrollableSites', []);
  const currentSite = window.location.hostname;

  // Check if the current site is in the list and apply CSS
  if (sites.includes(currentSite)) {
    appendCSS();
  }

  // Add keyboard shortcut [Ctrl + Alt + Shift + X]
  window.addEventListener('keydown', (e) => {
    if (e.key === 'X' && e.altKey && e.shiftKey && e.ctrlKey) {
      appendCSS();
    }
  });

  // Function to add the current site to the list
  function addCurrentSite() {
    if (!sites.includes(currentSite)) {
      sites.push(currentSite); // eslint-disable-next-line no-undef
      GM_setValue('scrollableSites', sites);
      alert(`${currentSite} has been added to the list, effective after refresh.`);
    } else {
      alert('This site is already in the list.');
    }
  }

  // Add menu command to add the current site
  // eslint-disable-next-line no-undef
  GM_registerMenuCommand('Set current site to append CSS by default.', addCurrentSite);
})();