问答
技术

站点的灰色调效果有点厉害

我保留了404时台湾友人开发的反吊丧脚本,稍微试了一下没有效果,不知道是怎么做到的,比政府举行吊丧的技术还强,如果害怕泄密被政府利用能不能私信一下原理,就是好奇。

这是反吊丧脚本的代码

// ==UserScript==
// @name         清明节要拒绝强行吊丧
// @namespace    https://github.com/axiref/?404-gray
// @version      1.55
// @description  拒绝被强制参加4月4号的网页黑白葬礼
// @author       axiref
// @include      http://*/*
// @include      https://*/*
// @grant        GM_addStyle
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';
    function getFirstByClass(className) {
        return document.getElementsByClassName(className)[0]
    }
    function getManyElementsByClass (classNameList) {
        var eleList = []
        for (var k in classNameList) {
            var className = classNameList[k]
            eleList.push(getFirstByClass(className))
        }
        return eleList
    }
    var elements = [
        document.documentElement,
        document.body
    ]
    var robberList = [
        "www.gov.cn",
        "paper.people.com.cn",
        "cpc.people.com.cn"
    ]
    var host = window.location.hostname
    // 针对QQ邮箱
    if (host == "mail.qq.com") {
        GM_addStyle(".header,.login_pictures,.xm_login_container,.footer{filter: none !important}")
    }
    // 针对163邮箱
    if (host == "mail.163.com") {
        window.onload=function(){
            getFirstByClass("header-163logo").classList.remove("gray")
        }
    }
    // 针对新浪
    if (host == "www.sina.com.cn") {
        GM_addStyle("*{filter: none !important;}")
    }
    // 针对手机新浪网
    if (host == "sina.cn") {
        window.onload=function(){
            getFirstByClass("hd").classList.remove("qingming")
        }
    }
    // 针对百度网盘
    if (host == "pan.baidu.com") {
        window.onload=function(){
            document.body.style.filter="none"
        }
    }
    // 针对3dm
    if (host == "www.3dmgame.com") {
        GM_addStyle(".header_wrap,.content,.Linkwrap,.fotter{filter: none !important;}")
        window.onload=function(){
            document.body.style = "filter: unset !important"
        }
    }
    // 针对百度搜索
    if (host == "www.baidu.com") {
        GM_addStyle("#head_wrapper{filter: none !important;}")
    }
    // 针对卡饭论坛
    if (host == "bbs.kafan.cn") {
        GM_addStyle("html, body {filter: none !important;}")
        var kf_style = "background:url(//a.kafan.cn/template/comeing_city/style/t2/bg.jpg) repeat-x 0 0 #f1f0f0 !important"
        window.onload=function(){
            document.body.style=kf_style
        }
    }
    // 取消网页灰度
    for (var k in elements) {
        var element = elements[k]
        element ? element.style.filter = "none" : null
    }
    // 让应该黑白的页面黑白
    if (robberList.indexOf(host) !== -1) {
        document.documentElement.style.filter="grayscale(100%)"
    }
    // 彩蛋
    if (host == "www.fmprc.gov.cn") {
        GM_addStyle(".main1_left,body{transition: filter 10s}")
        window.onload=function(){
            let winnieStyle = getFirstByClass("main1_left").style
            winnieStyle.filter="grayscale(100%)"
            setTimeout(function () {
                getFirstByClass("commend").innerHTML="<h1 style='font-size: 2em'>永 垂 不 朽</h1>"
                document.body.style.filter="grayscale(100%)"
        }, 4000)
        }
    }
})();

菜单
  1. konagi  

    啊插入程序代码好像有点乱,引用也不太行……算了,凑活看吧。

  2. mlsayu_rkesee  
    内容已隐藏
    内容已被作者本人或管理员隐藏。 如有疑问,请点击菜单按钮,查看管理日志以了解原因。
  3. 看客  
    内容已隐藏
    内容已被作者本人或管理员隐藏。 如有疑问,请点击菜单按钮,查看管理日志以了解原因。
  4. 貉龍君  

    難怪踏入凌晨零時後總覺得顏色怪怪的,

  5. thphd   2047前站长
  6. karasu  

    取消全部filter特效的脚本,应该适用于任何HTML5网站。

    document.querySelectorAll('*').forEach((function f(e){if(e.tagName=='IFRAME'&& e.contentDocument!=null){e.contentDocument.querySelectorAll('*').forEach(f)};if(getComputedStyle(e).filter!='none'){console.log(e,getComputedStyle(e).filter);e.style.setProperty('filter','none' ,'important')}}))
    
  7. karasu  

    有矛就有盾,想到了一个可以绝对避免客户端反吊丧的方法: 服务器上预处理全部元素,必要时文本元素先转换成图片再做特效处理,防止客户端用css恢复文本颜色,转换和处理后再传回客户端.
    就是不知道共匪和站长哪个有兴趣为吊丧投入如此精力啦. 尤其是政府共匪网站如果调试不好恐怕全站瘫痪影响大大的.