百度主页伪装成谷歌

🐶把百度搜索伪装成谷歌搜索

目前為 2022-01-20 提交的版本,檢視 最新版本

// ==UserScript==
// @name         百度主页伪装成谷歌
// @namespace    com.zhaolei
// @version      0.1
// @description  🐶把百度搜索伪装成谷歌搜索
// @author       赵磊
// @match        https://www.baidu.com/*
// @icon         view-source:https://www.baidu.com/favicon.ico
// @grant        none
// @license      GPL-3.0
// ==/UserScript==

(function() {
    'use strict';
    function del(title, idOfParent, path, width, height, margin) {
        document.title = title
        let parent = document.getElementById(idOfParent)
        while(parent.hasChildNodes())
        {
            parent.removeChild(parent.firstChild);
        }
        let newEle = document.createElement('img')
        newEle.setAttribute('src', 'http://r.photo.store.qq.com/psc?/V50ivL1t10zlq30Axslc3uGZmh0S5ltf/45NBuzDIW489QBoVep5mcUjdk7aGv0CXuNkULqVLVwvOeo8JhFVAoUZkQX8uYsBWLx5DQX0NVnlN.0GQI7hjlfR6*vTDp.7T6MpDkH8B0e4!/r')
        newEle.setAttribute('width', '272')
        newEle.setAttribute('height', '92')
        if (margin) {
            newEle.setAttribute('style', 'margin-top:46px;margin-bottom:46px')
        }
        parent.appendChild(newEle)
        let searchButton = document.getElementById('su')
        searchButton.setAttribute('value', '谷歌一下')
    }
    function changeBaidu(className) {
        let resultCount = document.getElementsByClassName(className)[0]
        resultCount.innerText = resultCount.innerText.replace(/^百度/, '谷歌')
    }
    switch (window.location.href) {
        case 'https://www.baidu.com/': {
            let url = 'http://r.photo.store.qq.com/psc?/V50ivL1t10zlq30Axslc3uGZmh0S5ltf/45NBuzDIW489QBoVep5mcUjdk7aGv0CXuNkULqVLVwvOeo8JhFVAoUZkQX8uYsBWLx5DQX0NVnlN.0GQI7hjlfR6*vTDp.7T6MpDkH8B0e4!/r'
            let margin = 'margin-top:46px;margin-bottom:46px'
            del('谷歌一下,你就知道😉', 'lg', url, '272', '92', margin)
            document.getElementById('s-top-left').remove()
            document.getElementById('bottom_layer').remove()
            break;
        }
        case (window.location.href.match(/https:\/\/www.baidu.com\/s\?.*/)).input: {
            let url = 'http://r.photo.store.qq.com/psc?/V50ivL1t10zlq30Axslc3uGZmh0S5ltf/45NBuzDIW489QBoVep5mcQXSvzgaNIOHHKfKY37F.eWhtdAqlzeeAeLIKPX0A1Qap4TLwyQbVJNWnnIJLJcTZvz6b18PTCwSjiUtHB8wKX4!/r'
            let title = document.title.replace(/_百度搜索$/, '_谷歌搜索')
            del(title, 'result_logo', url, '101', '33', '')
            changeBaidu('hint_PIwZX')
            changeBaidu('toindex')
            break;
        }
        default:
            break;
    }
})();