Notice: To Install styles, click the "Show Css Code" button first. The install button will work after that.
The devs are no longer actively involved in the forum, so any bug reports regarding the extension or website should be sent to them directly at contact@userstyles.org.

{background: !moreimportantthanimportant} (style vs !important)

edited June 2018 in Style Development Chrome
How to make background transparent if it's have "background:#fefefe !important" on site? Is it possible?
I tried some manipulations with width, height and padding but something i do wrong

Comments

  • edited June 2018 Firefox

    You can't fight an inline !important with external CSS.

    I suggest writing your style as usual but remove the inline styles with some Javascript (apply with an extension like Tampermonkey).
    For example:

    // ==UserScript==
    // @name         Remove inline important background
    // @namespace    stonecrusher
    // @version      0.1
    // @description  Removes inline styles that are specified in the script
    // @author       stonecrusher
    // @match        https://www.example.com/*
    // @grant        none
    // ==/UserScript==
    /* jshint esversion: 6 */
    
    (function() {
        'use strict';
    
        var nodeList = document.querySelectorAll("#your > .selectors, #here ~ .separated > .by.commas, .have.fun"),i;
        for (i = 0; i < nodeList.length; ++i) {
            nodeList[i].style.removeProperty("background");
        }
    
    })();
    
  • thanks, how can I apply this code only for one sitE?

  • edited June 2018 Firefox

    You can fight if this !important is *.css on this page or in <style> - must use same XPath / CSS selectors.

  • thanks, how can I apply this code only for one sitE?

    It will only be active for sites specified in the @match statement.

    Here is some more information, but probably unnecessary. Just paste your desired URL / Domain after // @match and you'll be fine.
    * resembles wildcard.

    https://developer.chrome.com/extensions/match_patterns

Sign In or Register to comment.