GiCon

Add favicon`s on google search page.

当前为 2018-02-23 提交的版本,查看 最新版本

// ==UserScript==
// @name           GiCon
// @version        0.1.2
// @description    Add favicon`s on google search page.
// @description:ru Добавляет иконки сайтов в поисковый ответ.
// @author         gvvad
// @include        http*://google.*/*
// @include        http*://www.google.*/*
// @include        http*://google.*.*/*
// @include        http*://www.google.*.*/*
// @noframes
// @grant          none
// @license        GPL-3.0+; http://www.gnu.org/licenses/gpl-3.0.txt
// @namespace      https://gf.qytechs.cn/users/100160
// ==/UserScript==

(function() {
    'use strict';
    //custom css rule for icon
    document.styleSheets[0].insertRule(".gicofav{position:absolute; top:0.1em; left:-1.8em;}");

    //shedule on page load event
    document.documentElement.addEventListener("load", () => {
        try {
            let rcnt = document.querySelector("#rcnt");
            if (!rcnt) return;
            if (rcnt.querySelector(".gicofav")) return;

            let lst = rcnt.querySelectorAll(".g");
            if (!lst) return;

            let reg = /https?:\/\/.+?\//;
            for (var i = 0; i < lst.length; ++i) {
                try {
                    let rc = lst[i].querySelector(".rc");
                    let href = lst[i].querySelector(".r").firstChild.href;

                    let nhref = reg.exec(href);
                    let el = document.createElement("img");
                    el.className = "gicofav";
                    el.src = "http://www.google.com/s2/favicons?domain=" + nhref;

                    rc.insertBefore(el, rc.childNodes[0]);
                } catch(e) {
                    continue;
                }
            }
        } catch(e) {}
    }, true);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址