代码之家  ›  专栏  ›  技术社区  ›  Boontawee Home

无法删除某些网页上的灰度过滤器

  •  1
  • Boontawee Home  · 技术社区  · 7 年前

    // ==UserScript==
    // @name         Remove Grayscale
    // @namespace    Remove Grayscale
    // @description  Remove Grayscale
    // @version      1
    // @author       You
    // @match        http*://*/*
    // ==/UserScript==
    
    //var script = document.createTextNode("<style type='text/css'>html, body, img {filter:none !important; -webkit-filter:none !important;}</style>");
    var script = document.createElement("script");
    script.type="text/css";
    script.innerHTML="html, body, img {filter:grayscale(0) !important; -webkit-filter:grayscale(0) !important;}";
    document.getElementsByTagName('head')[0].appendChild(script);
    //document.head.appendChild(script);
    
    //document.head.setAttribute("style","filter:none !important; -webkit-filter:none !important;");
    document.body.setAttribute("style","filter:grayscale(0) !important; -webkit-filter:grayscale(0) !important;");
    document.html.setAttribute("style","filter:grayscale(0) !important; -webkit-filter:grayscale(0) !important;");
    

    它没有工作 pptvhd36.com .

    1 回复  |  直到 7 年前
        1
  •  1
  •   Brock Adams firebus    7 年前

    注:

    1. 总是 look in the browser/error console

      你不能设置 <html> 这样的风格。

    2. the Stylish extension 适用于大多数浏览器,是更快更容易的选择。

    3. GM_addStyle .

    // ==UserScript==
    // @name        pptvhd36.com, Remove Grayscale
    // @match       https://www.pptvhd36.com/*
    // @grant       GM_addStyle
    // ==/UserScript==
    
    GM_addStyle ( `
        html {
            filter:grayscale(0) !important;
            -webkit-filter:grayscale(0) !important;
        }
    ` );