Greasy Fork

Greasy Fork is available in English.

聚合搜索,支持百度,谷歌,必应,360搜索,搜狗,淘宝,京东,知乎,B站,豆瓣,优酷,爱奇艺,GitHub等

聚合搜索,支持百度,谷歌,必应,360搜索,搜狗,淘宝,京东,知乎,B站,豆瓣,优酷,爱奇艺,GitHub,云盘精灵,大圣盘,大力盘,小昭来啦,小可搜搜,支持谷歌搜索链接新窗口打开,可以在下面的自定义处自定义自己的内容,也在代码开关中开启或关闭百度聚合功能及谷歌搜索链接新窗口打开功能。

当前为 2020-09-19 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         聚合搜索,支持百度,谷歌,必应,360搜索,搜狗,淘宝,京东,知乎,B站,豆瓣,优酷,爱奇艺,GitHub等
// @namespace    http://bbs.91wc.net/aggregate-search.htm
// @version      1.2.3
// @description  聚合搜索,支持百度,谷歌,必应,360搜索,搜狗,淘宝,京东,知乎,B站,豆瓣,优酷,爱奇艺,GitHub,云盘精灵,大圣盘,大力盘,小昭来啦,小可搜搜,支持谷歌搜索链接新窗口打开,可以在下面的自定义处自定义自己的内容,也在代码开关中开启或关闭百度聚合功能及谷歌搜索链接新窗口打开功能。
// @author       Wilson
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAEZ0lEQVRYR8WWX2hbVRzHv7+TOhxsZfembIyJdrYncVWk2K5T+2JBO9Tpi7QPOqHzoX9u2sIGivig26MKU1xyb7upHSIIDkQdOlB0fahM2TJ0uLXNTedgRZgmN+0qzLbJ/clNk5ql+XMTqJ6nkPM7v+/nfs/v/M4h/M+DKtVX3zNrxQbhSy7bm7Jr54bkeKV5svGuAJSRmaeIuQvMewDsKiC2wOCTgDiT0BrPVAJTEkAJRvaRwOsA7QZjFoRzTLjo/OYUZj2C6xlcDxIPA3gEQC0YHwryvBXT7p12A1IUwKubAQaCaWGBo9aAfKdUQvWEeReWcAiEgwBiDNGT0Bq+KgdREMAbivQw0RiAyxDotvrllXKJsvOqbnYB+BRAAgJPW/3yXKm1awA2Bye9d4iaGAPjCU12uBXOj1N1k0GYgk2dVqDxerE8awBUIzoG5mZ7saZj7uDOuWoBthwzHxMenGVCMDEgh1wBKCFTI0KIQX0JrfH4qq0jkSesft+3lcKoemQUoF7Y3GkNFl5/mwOqEb3EzEsJTbZmxRR9pp9gH7KZu+cCvp8rgajToy02+AKAMUuTLxVauwpQN3ptu51a/p0ZwURgxTI1FH0UxD8AOGVpsrsS8Zyi/JoBmdCkLAmgGDP7iO3TxPxcPOD7zAn26hGDQftTSTTPD8uZagAUw3yBGB+nYDfMa/6r+TlWHVBD04dB4g1K2bviQ/6ptAO66Xw9LE22VyOe/ohj0/exR0zaKXQUatmrAF7d/JKBZ2o31my8dmDn3xmABQDvW5p0mktVo37stztv3kreKgughMwQEbSlJLb+NSz/zABMgzlsBXzPV6UOYJsR3brMfKMsgNcwX2TGRykbLfOD8uIKQOQTgB6yNOmvFqBuZKbVtu3zxNwUD/gmi9aAol99kJD6hZgPxAO+kyunIFMXOf9VCqIY5qsEHLHE/Cb0tS4XBXAmlJD5hwC+iQfk/pxj9CNA24ipOx5oOF8pgGqYlxhYTgzIlpLHMA2gm18Q8KwAtca0xnDahRGziVJ4LRfKLYSiR3sJPAq2j1gB/+HyAEa0nZgnAD5uab4+t0LF4hTdvEDAdkuTO4rFrLmMvEb0TWZ+pRS1GzBVN50ruSv/XilZA//ue2QKIH+xo1MOIFu8K3FsWZrP69qBnOKbANDuOIGUOGoNy5tlhUfMJjC9DOaevNjLliYfKFsD+QHZ3pB+GTGNEdsT8UHfT/lxih59kji1ByScjllbEJToO2ug8XFXW5AblOkPbwPoTBsKLAKYBXCdQPVwHqWZQcBpBvYC2FDErTW3qqtnuZPMa0y3gcVuG2gj5jYQ7WAgTIwwQ4Q9jHBssCGCs1yjTpo3AFLdQLgGKLf/ufN1H0xtthc9vwK4u8i6bkuTp5y5dQFwEmcuoe8B3F8AYnUr1g3AEd0SvHKPEDWfA9R8GwTbvVbAf2JdHcgKZh4k72KlOJ0iHk967K6FPn/sPwFY7SuGuddOYjH/VbSuW+CmcP8Bvs7fMICKGssAAAAASUVORK5CYII=
// @require      https://cdn.jsdelivr.net/npm/[email protected]/jquery.min.js
// @match        *://www.baidu.com/*
// @match        *://www.google.com/search*
// @match        *://www.google.com.hk/search*
// @match        *://www.bing.com/search*
// @match        *://www.so.com/s*
// @match        *://www.sogou.com/web*
// @match        *://fanyi.sogou.com/*
// @match        *://fanyi.baidu.com/*
// @match        *://github.com/search*
// @match        *://www.zhihu.com/search*
// @match        *://www.douban.com/search*
// @match        *://www.yunpanjingling.com/search/*
// @match        *://www.dashengpan.com/search*
// @match        *://www.dalipan.com/search*
// @match        *://www.xiaozhaolaila.com/s/search*
// @match        *://www.xiaokesoso.com/s/search*
// @match        *://www.youtube.com/results*
// @match        *://segmentfault.com/search*
// @grant        GM_setValue
// @grant        GM_getValue
// @license      GPL License
// @grant        unsafeWindow
// ==/UserScript==

//避免jQuery冲突
this.$ = this.jQuery = jQuery.noConflict(true);

(function() {
    'use strict';

    /////////////// 变量配置 ///////////////////////////

    //是否开启谷歌搜索链接新窗口打开
    var is_google_blank = 1;

    //是否开启百度聚合搜索
    var is_open_multi_search=1;

    var main=function(){
        //谷歌搜索链接新窗口打开
        if(document.domain.indexOf("google.com")!==-1 && is_google_blank){
            $("#search div.r a").attr("target", "_blank");
        }

        /////////////// 聚合搜索开始 //////////////////////////////////////////////

        if(!is_open_multi_search){
            return;
        }
        var getY2BVal = function(name){
            var ytbobj=document.getElementsByName("search_query");
            if(ytbobj && ytbobj[0] && ytbobj[0].value){
                return ytbobj[0].value;
            };
            return '';
        };
        var getkw = function(){
            var kw=$("#kw").val()||$("input[name=q]").val()||$("#upquery").val()||$("#baidu_translate_input").val()||
                $("#trans-input").val()||$("#Popover2-toggle").val()||$("input.word").val()||$("input[name=q]").eq(1).val() ||
                $("input[name=keyword]").val()||$("input[name=searchInput]").val()||getY2BVal()||
                $(".right_contents input.selector_input").val()||"";
            return encodeURIComponent(kw.replace(/^\s+|\s+$/gm,''));
        };
        var bindSearch=function(force){
            force = force||0;
            if(!force && $("#wish_search_wrapper").length > 0){
                return;
            }
            //搜索列表HTML,可在这里调整显示顺序和列表显示效果
            var html=`<style>
#wish_search_list a{display:inline-block;padding:0 4px;font-size: 15px;width: 100%;}
#wish_search_list a:hover,.wish_s_item:hover{background:#37a;color:#fff;}
.wish_s_item{padding:4px 1px;}
</style>
<div id="wish_search_wrapper" style="position:fixed;top:60px;left:20px;background:#fff;z-index:8888">
<div><a href="javascript:;" id="wish_search_openclose">关闭</a></div>
<div id="wish_search_content">
<div id="wish_search_list" style="overflow:hidden;width:101px;">
<!-------------------------这里可以自定义自己的内容哦----------------------->

<!--google-->
<div class="wish_s_item"><a href="https://www.google.com/search?q=#keyword#">谷歌搜索</a></div>
<!--百度搜索-->
<div class="wish_s_item"><a href="https://www.baidu.com/s?wd=#keyword#">百度搜索</a></div>
<!--bing-->
<div class="wish_s_item"><a href="https://cn.bing.com/search?q=#keyword#">Bing搜索</a></div>
<!--360搜索-->
<div class="wish_s_item"><a href="https://www.so.com/s?q=#keyword#">360搜索</a></div>
<!--搜狗-->
<div class="wish_s_item"><a href="https://www.sogou.com/web?query=#keyword#">搜狗搜索</a></div>
<!--GitHub-->
<div class="wish_s_item"><a href="https://github.com/search?utf8=✓&q=#keyword#">GitHub</a></div>
<!--stackoverflow-->
<div class="wish_s_item"><a href="https://stackoverflow.com/search?q=#keyword#" target="_blank">Stackoverflow</a></div>
<!--segmentfault-->
<div class="wish_s_item"><a href="https://segmentfault.com/search?q=#keyword#">Segmentfault</a></div>
<!--知乎-->
<div class="wish_s_item"><a href="https://www.zhihu.com/search?type=content&q=#keyword#">知乎搜索</a></div>
<!--百度翻译-->
<div class="wish_s_item"><a href="https://fanyi.baidu.com/#en/zh/#keyword#">百度翻译</a></div>
<!--搜狗翻译-->
<div class="wish_s_item"><a href="https://fanyi.sogou.com/?keyword=#keyword#">搜狗翻译</a></div>
<!--谷歌翻译-->
<div class="wish_s_item"><a href="https://translate.google.com/?hl=zh-CN&tab=wT0#view=home&op=translate&sl=auto&tl=zh-CN&text=#keyword#" target="_blank">谷歌翻译</a></div>
<!--YouTube-->
<div class="wish_s_item"><a href="https://www.youtube.com/results?search_query=#keyword#">YouTube</a></div>
<!--Quora-->
<div class="wish_s_item"><a href="https://www.quora.com/search?q=#keyword#" target="_blank">Quora</a></div>
<!--淘宝-->
<div class="wish_s_item"><a href="https://s.taobao.com/search?q=#keyword#" target="_blank">淘宝搜索</a></div>
<!--京东-->
<div class="wish_s_item"><a href="http://search.jd.com/Search?keyword=#keyword#" target="_blank">京东搜索</a></div>
<!--B站-->
<div class="wish_s_item"><a href="http://search.bilibili.com/all?keyword=#keyword#" target="_blank">Bilibili搜索</a></div>
<!--豆瓣-->
<div class="wish_s_item"><a href="https://www.douban.com/search?source=suggest&q=#keyword#">豆瓣搜索</a></div>
<!--优酷-->
<div class="wish_s_item"><a href="https://so.youku.com/search_video/q_#keyword#" target="_blank">优酷搜索</a></div>
<!--爱奇艺-->
<div class="wish_s_item"><a href="https://so.iqiyi.com/so/q_%E5%A5%BD%E5%A5%BD#keyword#" target="_blank">爱奇艺搜索</a></div>
<!--云盘精灵-->
<div class="wish_s_item"><a href="https://www.yunpanjingling.com/search/#keyword#">云盘精灵搜</a></div>
<!--大圣盘-->
<div class="wish_s_item"><a href="https://www.dashengpan.com/search?keyword=#keyword#">大圣盘搜索</a></div>
<!--大力盘-->
<div class="wish_s_item"><a href="https://www.dalipan.com/search?keyword=#keyword#">大力盘搜索</a></div>
<!--小昭来啦-->
<div class="wish_s_item"><a href="https://www.xiaozhaolaila.com/s/search?q=#keyword#">小昭来啦</a></div>
<!--小可搜搜-->
<div class="wish_s_item"><a href="https://www.xiaokesoso.com/s/search?q=#keyword#">小可搜搜</a></div>

<!-------------------------自定义结束----------------------->
</div>
<div id="wish_search_more_wrapper" style="text-align:center;border-top:1px solid #ccc;">
<a id="wish_search_more_btn" href="javascript:;" style="display:inline-block;width:80px;height:50px;line-height:40px;font-size:16px;">更多</a>
</div>
<div>
</div>`;
            //追加搜索列表
            //var kw=getkw();
            //html = html.replace(/#keyword#/gm, kw);
            if($("#wish_search_wrapper").length > 0){
                $("#wish_search_wrapper").remove();
            }
            $("body").append(html);
            if(document.domain=='www.youtube.com'||document.domain=='www.quora.com'){
                $("#wish_search_wrapper").css({left:"auto", right:"20px"});
            }
            if(document.domain=='www.so.com'||document.domain=='www.bing.com'){
                $("#wish_search_wrapper").css({left:"15px"});
            }

            //设置列表高度
            var wish_search_list = $('#wish_search_list');
            var listH=wish_search_list.outerHeight(true);
            var winH=$(window).height()-70;
            if(listH > winH){
                winH -= 50;
                $("#wish_search_more_wrapper").show();
                $("#wish_search_more_btn").click(function(){
                    $("#wish_search_more_wrapper").hide();
                    winH += 44;
                    wish_search_list.height(winH);
                    $("#wish_search_list").css("overflow-y", "auto");
                });
            }
            wish_search_list.height(winH);

            //列表关闭
            var wish_s_open_key="__wish_s_open";
            $("#wish_search_openclose").click(function(){
                if(GM_getValue(wish_s_open_key, 1)){
                    //关闭
                    $("#wish_search_content").hide();
                    $(this).html("开启聚合搜索");
                    GM_setValue(wish_s_open_key, 0);
                } else {
                    //开启
                    $("#wish_search_content").show();
                    $(this).html("关闭");
                    GM_setValue(wish_s_open_key, 1);
                }
            });
            if(GM_getValue(wish_s_open_key, 1)){
                //开启
                $("#wish_search_content").show();
                $("#wish_search_openclose").html("关闭");
            } else {
                //关闭
                $("#wish_search_content").hide();
                $("#wish_search_openclose").html("开启聚合搜索");
            }

            //初始化data-href链接
            $("#wish_search_list a").each(function(){
                var me=$(this);
                me.attr("data-href", me.attr("href"));
            });

            //链接跳转
            $("#wish_search_list a").click(function(){
                var me=$(this);
                if(me.attr("href").indexOf('#keyword#')!==-1){
                    var href=me.attr("href").replace(/#keyword#/i, getkw());
                    me.attr("href", href);
                }
                return true;
            });

            //动态修改链接
            $("#wish_search_list a").on('mouseover', function(){
                var me=$(this);
                var href=me.attr("data-href").replace(/#keyword#/i, getkw());
                me.attr("href", href);
            });
        };

        //////// main ////////////
        //百度翻译
        if(document.domain.indexOf("fanyi.baidu.com")!==-1){
            bindSearch();
        }
        //百度搜索
        else if(document.domain.indexOf("baidu.com")!==-1){
            //监控百度首页变化
            $('#wrapper_wrapper').on("DOMNodeInserted", function(){
                bindSearch();
            });

            //匹配百度搜索页
            if(location.href.indexOf("wd=")!==-1){
                bindSearch();
            }
        }
        //其他
        else {
            bindSearch();
        }
        /////////////// 聚合搜索结束 //////////////////////////////////////////////
    };

    //开始执行
    main();

})();