// ==UserScript== // @name 搜索跳转 // @namespace http://www.findspace.name // @author Alan // @version 1.0.3 // @description 通用搜索框 // @require http://cdn.bootcss.com/jquery/2.2.4/jquery.js // @include https://www.baidu.com/* // @include https://www.google* // @include http://cn.bing.com/search?q* // @include http://www.bing.com/search?q=* // @copyright 2015+, f9y4ng ,Find // @grant none // @downloadURL none // ==/UserScript== var classtypeTop = { position: 'fixed', top: '0px', display: 'block', width: '100%' }; var classtype = { position: 'relative', top: '0px', display: 'block', width: '100%' }; $(".faviconT").hide(); $("#content_right").hide(); $(window).load(function(){   $(window).bind('scroll resize', function(){   var $this = $(this);   var $this_Top=$this.scrollTop();   if($this_Top < 150){ $("#hdtbSum").css(classtype);    }    if($this_Top > 150){ $("#hdtbSum").css(classtypeTop);     }   }).scroll();  }); $(document).keypress(function(e) { // 回车键事件 if(e.which == 13) { console.log("回车啦"); var ss = $("#kw").val(); Baidu(ss); } }); $("#wrapper,.mw,#b_content").append('
百度谷歌 必应 知乎 淘宝 京东 当当 豆瓣 翻译 地图
'); $(".SearchTo").on("click",function(){ var sFlag = $(this).attr('id'); var sVal = $("#kw").val()||$("#lst-ib").val()||$("#sb_form_q").val()||$("[name='q']").val(); sVal = encodeURIComponent(sVal); if (sFlag == "" || sFlag == undefined) {return false;} switch (sFlag) { case "abd": Baidu(sVal); break;//百度搜索 case "agg": GoogleJX(sVal); break;//谷歌搜索 case "ajd": JDSearch(sVal); break;//京东 case "atb": TBSearch(sVal); break;//淘宝 case "azh": ZHSearch(sVal); break;//知乎 case "adb": Douban(sVal); break;//豆瓣 case "adm": PangCI(sVal); break;//动漫 case "add": DangDang(sVal); break;//当当 case "adt": Ditu(sVal); break;//地图 case "ayy": YInyue(sVal); break;//音乐 case "abl": BiliBili(sVal); break;//bilibili case "afy": Translate(sVal); break;//翻译 case "abg": sBing(sVal);break; default: Baidu(sVal); break; } return false; }); function Baidu(argument) { OpenUrl("https://www.baidu.com/s?wd=" + argument); } function GoogleJX(argument) { OpenUrl("https://www.google.com/search?q=" + argument); } function JDSearch(argument) { OpenUrl("http://search.jd.com/Search?enc=utf-8&keyword=" + argument); } function TBSearch(argument) { OpenUrl("https://s.taobao.com/search?q=" + argument); } function ZHSearch(argument) { OpenUrl("https://www.zhihu.com/search?q=" + argument); } function Douban(argument) { OpenUrl("https://www.douban.com/search?q=" + argument); } function PangCI(argument) { OpenUrl("http://218.50.4.4/s/" + argument + "/td_0"); } function DangDang(argument) { OpenUrl("http://search.dangdang.com/?key=" + argument); } function Ditu(argument) { OpenUrl("http://ditu.amap.com/search?query=" + argument); } function YInyue(argument) { OpenUrl("http://music.163.com/#/search/m/?s=" + argument + "&type=1"); } function BiliBili(argument) { var v = "http://search.bilibili.com/all?keyword=" + argument + "&type=1"; if (!argument) { v = "http://www.bilibili.com/"; } OpenUrl(v); } function sBing(argument) { var v = "http://cn.bing.com/search?q=" + argument; OpenUrl(v); } function Translate(argument) { OpenUrl("http://fanyi.baidu.com/#zh/en/" + argument); } function OpenUrl(surl) { window.location.href=surl; }