AntiImportant

Tarayıcı üzerinde çalışan !important temizleme kütüphanesi

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.greasyfork.org/scripts/582798/1851893/AntiImportant.js

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

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

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         AntiImportant
// @namespace    http://tampermonkey.net/
// @version      1
// @description  Tarayıcı üzerinde çalışan !important temizleme kütüphanesi
// @author       Atilla
// @license MIT
// ==/UserScript==
((rootElement) => {
  // İç fonksiyon: Sadece verilen elemanı ve alt elemanlarını temizler
  const clean = (el) => {
    if (!el || el.nodeType !== 1) return;
    
    const elements = [el, ...el.querySelectorAll("*")];
    
    elements.forEach((node) => {
      const style = node.style;
      if (!style || style.length === 0) return;

      // Performans için canlı listeyi diziye kopyala
      const props = Array.from(style);
      props.forEach((prop) => {
        if (style.getPropertyPriority(prop) === "important") {
          style.setProperty(prop, style.getPropertyValue(prop), "");
        }
      });
    });
  };

  // 1. Mevcut DOM'u temizle
  clean(rootElement);

  // 2. Yeni eklenenleri takip et ve temizle
  new MutationObserver((mutations) => {
    mutations.forEach((m) => m.addedNodes.forEach(clean));
  }).observe(rootElement, { childList: true, subtree: true });
})(document.body);