Toggle CSS Style

Toggle CSS Stylesheets. Hotkey: Command + Shift + F3

Stan na 18-07-2023. 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        Toggle CSS Style
// @namespace   i2p.schimon.toggle-style
// @description Toggle CSS Stylesheets. Hotkey: Command + Shift + F3
// @homepageURL https://greasyfork.org/en/scripts/466066-toggle-css-style
// @supportURL  https://greasyfork.org/en/scripts/466066-toggle-css-style/feedback
// @copyright   2023, Schimon Jehudah (http://schimon.i2p)
// @license     MIT; https://opensource.org/licenses/MIT
// @icon        data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj48dGV4dCB5PSIuOWVtIiBmb250LXNpemU9IjkwIj7wn5SbPC90ZXh0Pjwvc3ZnPgo=
// @match       *://*/*
// @version     23.06
// @run-at      document-end
// ==/UserScript==

var docHead, styleSheets = [];
document.addEventListener('keyup', hotkey, false);

function hotkey(e) {
  // set hotkey Command + Shift + F3
  if (e.metaKey && e.shiftKey && e.which == 114) {
    toggleStylesheets();
    //toggleHead();
  }
}

function toggleStylesheets() {
  if (document.head.querySelector('link[rel="stylesheet"]') ||
      document.head.querySelector('style')) {
    for (const style of document.head.querySelectorAll('link[rel="stylesheet"]')) {
      styleSheets.push(style);
      style.remove();
    }
    for (const style of document.head.querySelectorAll('style')) {
      styleSheets.push(style);
      style.remove();
    }
  } else {
    for (const style of styleSheets) {
      document.head.append(style);
    }
  }
}

function toggleHead() {
  if (document.head) {
    docHead = document.head;
    document.head.remove();
  } else {
    document.documentElement.prepend(docHead);
  }
}