GoogleFullSearchButton

Add to the Google Full Search button.

目前為 2015-05-30 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         GoogleFullSearchButton
// @name:zh-CN   谷歌全面搜索按钮
// @namespace    http://www.coofly.com/
// @version      1.0
// @description  Add to the Google Full Search button.
// @description:zh-cn 给Google添加上全面搜索按钮。
// @author       Coofly
// @match        http://tampermonkey.net/scripts.php
// @include        http://*.google.*/search*
// @include        https://*.google.*/search*
// @include        http://*.google.*/webhp*
// @include        https://*.google.*/webhp*
// @grant        none
// ==/UserScript==

(function(){
    var intervalId = -1;
    
    function AddFullSearchButton ()
    {
        var abCtls = document.getElementById('ab_ctls');
        if (null === abCtls) return;
        if (intervalId >= 0){
            clearInterval(intervalId);
            console.log('intervalId已取消');
        }

        var targetUrl = '';
        var btnClass = '';
        if (location.href.indexOf('&safe=off') >= 0)
        {
            targetUrl = location.href.replace('&safe=off', '');
            btnClass = 'ab_button selected';
        }
        else
        {
            targetUrl = location.href + '&safe=off';
            btnClass = 'ab_button';
        }
        console.log('targetUrl = ' + targetUrl);

        var buttonHtml = '<li class="ab_ctl"><a href="' + targetUrl + '" class="' + btnClass + '">全面搜索</a></li>';

        abCtls.insertAdjacentHTML('afterbegin', buttonHtml);
    }
    
    var abCtls = document.getElementById('ab_ctls');
    if(null === abCtls)
    {
        intervalId = setInterval(AddFullSearchButton, 100);
        console.log('intervalId = ' + intervalId);
        return;
    }
    else
    {
        AddFullSearchButton();
    }
})();