AntiImportant

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

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.org/scripts/582798/1851893/AntiImportant.js

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);