GiCon

Add favicon`s on google search page.

目前為 2018-03-15 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name           GiCon
// @version        0.1.3
// @description    Add favicon`s on google search page.
// @description:ru Добавляет иконки сайтов в поисковый ответ.
// @author         gvvad
// @run-at         document-start
// @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://greasyfork.org/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", function() {
        try {
            let lst = rcnt.querySelectorAll(".g");
            if (!lst) {
                return;
            }

            let reg = /https?:\/\/.+?\//;
            for (let item of lst) {
                try {
                    if (item.querySelector(".gicofav")) {
                        continue;
                    }

                    let rc = item.querySelector(".rc");

                    let nhref = reg.exec(item.querySelector(".r").querySelector("a").href);
                    let nimg = document.createElement("img");
                    nimg.setAttribute("class", "gicofav");
                    nimg.setAttribute("src", "http://www.google.com/s2/favicons?domain=" + nhref);

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