Greasy Fork

Greasy Fork is available in English.

多吉搜索直达按钮

给百度、360、搜狗、必应、谷歌等搜索引擎的结果页加入多吉搜索按钮,一键跳转到多吉搜索进行相同关键词的检索。

当前为 2019-11-23 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         多吉搜索直达按钮
// @description  给百度、360、搜狗、必应、谷歌等搜索引擎的结果页加入多吉搜索按钮,一键跳转到多吉搜索进行相同关键词的检索。
// @icon         https://www.dogedoge.com/assets/doge_ico.png
// @namespace    http://greasyfork.icu/zh-CN/users/393603-tsing
// @version      3.0
// @author       Tsing
// @include      *://ipv6.baidu.com/s?*
// @include      *://www.baidu.com/s?*
// @include      *://www.so.com/s?*
// @include      *://www.sogou.com/web?*
// @include      *://www.sogou.com/sie*
// @include      *://www.sogou.com/sogou*
// @include      *://www.sogou.com/tx*
// @include      *://*.bing.com/search?*
// @include      *://www.google.com/search?*
// @include      *://www.google.com.*/search?*
// @include      *://www.dogedoge.com/results?*
// @require      https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// @grant        none
// @note         2019.10.31 V1.0 在百度搜索的结果页加入多吉搜索按钮。
// @note         2019.11.06 V2.0 听取多吉搜索开发者 @nicoljiang 的建议,给检索关键词进行 urlencode 编码,并新增支持360、搜狗、必应搜索。给多吉搜索选择一个特征色号:#dd2248,保证视觉统一性。
// @note         2019.11.16 V2.1 感谢多吉搜索首页(https://dogedoge.com)推广该脚本!本次去除了各搜索引擎结果页面上按钮偶尔出现的下划线,新增了部分颜色动效,和原网站的一致性更高。
// @note         2019.11.20 V2.2 新增支持谷歌搜索引擎,感谢Greasy Fork站点网友 @魏信壹 的建议 。
// @note         2019.11.23 V3.0 当用户修改输入框中的检索内容然后直接点击多吉按钮时,可以实时更新多吉搜索的检索式。同时在多吉搜索的结果页面新增了一个Google的搜索按钮。
// ==/UserScript==

(function() {
    'use strict';

    var hostname = window.location.hostname;

    if(hostname.match(RegExp(/baidu.com/))){
        // 百度搜索
        var url_baidu = "https://www.dogedoge.com/results?q=" + encodeURIComponent($("#kw").val()) + "&from=TsingScript";
        $("#form").append('<span style="display: inline-block;"><a href="' + url_baidu + '" target="_blank" title="使用多吉搜索引擎检索该关键词" id="dogedoge" style="display:block; float:left; font-size:14px; text-align:center; text-decoration:none; width:100px; height:33px; line-height:33px; margin-left:5px; color:#fff; letter-spacing:1px; background:#3385ff; border-bottom:1px solid #2d78f4; outline:medium;" onmouseover="this.style.background=\'#317ef3\'" onmouseout="this.style.background=\'#3385ff\'">多吉搜索</a></span>')
        $("#kw").change(function(){ // 用户修改页面上输入框中的内容,然后直接点击多吉按钮,需要实时更新href。
            var url_baidu_new = "https://www.dogedoge.com/results?q=" + encodeURIComponent($("#kw").val()) + "&from=TsingScript";
            $("#dogedoge").attr('href',url_baidu_new);
        });

    }else if(hostname.match(RegExp(/so.com/))){
        // 360搜索
        var url_360 = "https://www.dogedoge.com/results?q=" + encodeURIComponent($("#keyword").val()) + "&from=TsingScript";
        $(".adv-search-wrap").after('<span class="adv-search-wrap"><a href="' + url_360 + '" target="_blank" title="使用多吉搜索引擎检索该关键词" id="dogedoge" style="display:block; background:#19b955;height:38px;line-height:38px;width:90px;text-align:center; text-decoration:none; color:#ffffff;font-size:14px;" onmouseover="this.style.background=\'#1bc550\'" onmouseout="this.style.background=\'#19b955\'">多吉搜索</a></span>');
        $("#keyword").change(function(){
            var url_360_new = "https://www.dogedoge.com/results?q=" + encodeURIComponent($("#keyword").val()) + "&from=TsingScript";
            $("#dogedoge").attr('href',url_360_new);
        });

    }else if(hostname.match(RegExp(/sogou.com/))){
        //搜狗搜索
        var url_sogou = "https://www.dogedoge.com/results?q=" + encodeURIComponent($("#upquery").val()) + "&from=TsingScript";
        $(".querybox").append('<a href="' + url_sogou + '" target="_blank" title="使用多吉搜索引擎检索该关键词" id="dogedoge" class="sbtn1" style="text-align:center;text-decoration:none;line-height:34px;color:#333;" onmouseup="this.className=\'sbtn1\'" onmousedown="this.className=\'btnactive\'" onmouseout="this.className=\'sbtn1\'" onmouseover="this.className=\'btnactive\'">多吉搜索</a>');
        $("#upquery").change(function(){
            var url_sogou_new = "https://www.dogedoge.com/results?q=" + encodeURIComponent($("#upquery").val()) + "&from=TsingScript";
            $("#dogedoge").attr('href',url_sogou_new);
        });

    }else if(hostname.match(RegExp(/bing.com/))){
        //必应搜索
        var url_bing = "https://www.dogedoge.com/results?q=" + encodeURIComponent($("#sb_form_q").val()) + "&from=TsingScript";
        $("#sb_form").append('<a href="'+ url_bing + '" target="_blank" title="使用多吉搜索引擎检索该关键词" id="dogedoge" class="b_searchbox" style="display:inline-block; width:100px; line-height:32px; margin:0 0 0 10px; padding:5px; color:#444; font-size:16px; font-weight:500; text-align:center;text-decoration:none; border-radius:6px; border-color:#eee; box-shadow:0 0 0 1px rgba(0,0,0,.1), 0 2px 4px 0 rgba(0,0,0,.16)" onmouseover="this.style.background=\'#f5f5f5\'" onmouseout="this.style.background=\'#ffffff\'">多吉搜索</a>');
        $("#sb_form_q").change(function(){
            var url_bing_new = "https://www.dogedoge.com/results?q=" + encodeURIComponent($("#sb_form_q").val()) + "&from=TsingScript";
            $("#dogedoge").attr('href',url_bing_new);
        });

    }else if(hostname.match(RegExp(/google.com/))){
        //谷歌搜索
        var url_google = "https://www.dogedoge.com/results?q=" + encodeURIComponent($(".gLFyf.gsfi:first").val()) + "&from=TsingScript";
        $(".RNNXgb:first").append('<div style="display:inline-block; height:100%; width:80px; border:3px solid #ffffff; box-sizing: border-box; border-radius:30px;"><button id="dogedoge" type="button" style="height:100%; width:100%; border:none; outline:none; border-radius:30px; font-size:15px; cursor:pointer; background:#eeeeee;" onclick="window.open(\''+ url_google + '\')" title="使用多吉搜索引擎检索该关键词">多吉</button></div>');
        $(".gLFyf.gsfi:first").change(function(){
            var url_google_new = "https://www.dogedoge.com/results?q=" + encodeURIComponent($(".gLFyf.gsfi:first").val()) + "&from=TsingScript";
            $("#dogedoge").attr('onclick','window.open("'+ url_google_new + '")');
        });

    }else if(hostname.match(RegExp(/dogedoge.com/))){
        //给多吉搜索增加一个Google按钮
        var dogedoge_to_google = "https://www.google.com/search?q=" + encodeURIComponent($("#search_form_input").val()) + "&from=TsingScript";
        $("#search_form").after('<button id="dogedoge" type="button" style="display:block; height:44px; width:80px; margin-top:-44px; margin-left:596px; font-size:1.2em; color:#222222; background:#ffffff; outline:none; border:1px solid rgba(0,0,0,0.15); border-radius:4px; box-shadow:0 2px 3px rgba(0,0,0,0.06); cursor:pointer;" onclick="window.open(\''+ dogedoge_to_google + '\')" title="使用谷歌搜索该关键词">Google</button>');
        $("#search_form_input").change(function(){
            var dogedoge_to_google_new = "https://www.google.com/search?q=" + encodeURIComponent($("#search_form_input").val()) + "&from=TsingScript";
            $("#dogedoge").attr('onclick','window.open("'+ dogedoge_to_google_new + '")');
        });

    }

})();