把Google搜索伪装成百度搜索

用Google搜索,很多人看到屏幕后会问你怎么上Google的.所以当我们把Google的logo换成百度,他们就不会问那么多问题了!

< Feedback on 把Google搜索伪装成百度搜索

Review: Good - script works

§
Posted: 12-12-2023
     ...
    } else {//首页

        //网页标题
        document.title = document.title.replace(/Google/g, "百度一下,你就知道");

        //首页大logo
        let bannerLogo = document.querySelector("[id=hplogo]");
        bannerLogo.src = "//www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png";
        bannerLogo.removeAttribute("srcset");
        bannerLogo.width = 324;
        bannerLogo.height = 155;
        //修改paddingtop的设置方式,改为原值-20px.避免硬性设置.造成不同浏览器下位置错乱.
        let paddingTop = bannerLogo.style.paddingTop.replace("px", "");
        let paddingTopInt = parseInt(paddingTop);
        bannerLogo.style.paddingTop = (paddingTopInt - 20) + "px";

        //右上角Gmail
        var navigation = document.querySelectorAll('[role="navigation"] *');
        navigation.forEach(function(navigation) {
            navigation.innerHTML = navigation.innerHTML.replace(/Gmail/g, "邮箱");
        });

        //按钮
        var searchBtns = document.getElementsByName("btnK");
        for (var x = 0; x < searchBtns.length; x++) {
            searchBtns[x].value = searchBtns[x].value.replace(/Google\s?/, "百度");
        }

        //按钮下语言切换的提示 arnes提供
        var footnote = document.getElementById("SIvCob");
        if (footnote !== null) //某些ip下,可能没有SIvCob,谢谢BeefOnionDumplings提醒.
            footnote.innerHTML = footnote.innerHTML.replace(/Google\s?/, "百度");

        //底部的google
        var contentinfo = document.querySelectorAll('[role="contentinfo"] *');
        contentinfo.forEach(function(contentinfo) {
            contentinfo.innerHTML = contentinfo.innerHTML.replace(/Google/g, "百度");
        });
    }

我更新的首页部分代码: 1、顶部“Gamil”改“邮箱”。 2、底部不依赖ClassName,改用role定位,以自适应页面更新。 3、logo稍微放大,和原Google差不多大小

§
Posted: 12-12-2023

logo也改成id定位,有时节日logo alt=Google定不出来

Post reply

Đăng nhập để bình luận