您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
在网页右上角增加快捷搜索功能,功能如下:1.如果选择了文本,那么搜索文本,2.如果在百度,bing,谷歌,淘宝,京东,翻译等搜索框下,则搜索搜索框关键字。3.默认当前页面替换,单弹页面请按ctrl/shift/cmd键组合。摒弃了vue,因为和很多网站都存在冲突
当前为
// ==UserScript== // @name 搜索辅助小工具 - 淘宝,京东,百度,必应,谷歌,翻译等 // @namespace http://tampermonkey.net/ // @version 3.1 // @description 在网页右上角增加快捷搜索功能,功能如下:1.如果选择了文本,那么搜索文本,2.如果在百度,bing,谷歌,淘宝,京东,翻译等搜索框下,则搜索搜索框关键字。3.默认当前页面替换,单弹页面请按ctrl/shift/cmd键组合。摒弃了vue,因为和很多网站都存在冲突 // @require https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js // @author Zszen // @include https://* // @include http://* // @grant none // ==/UserScript== //https://unpkg.com/vue/dist/vue.js (function () { 'use strict' let isDebug = 0 DLOG('===小工具z==='); setTimeout(function () { DLOG('===init==='); let infos = [ {title: '百度搜索', link: "https://www.baidu.com/s?wd="}, {title: 'Bing搜索', link: 'https://www.bing.com/search?q='}, {title: 'Google搜索', link: 'https://www.google.com/search?q='}, {title: '百度翻译', link: 'https://fanyi.baidu.com/#en/zh/'}, {title: 'Google翻译', link: 'https://translate.google.cn/#view=home&op=translate&sl=en&tl=zh-CN&text='}, {title: '淘宝搜索', link: 'https://s.taobao.com/search?q='}, {title: '京东搜索', link: 'https://search.jd.com/Search?keyword='}, {title: '简书', link: 'https://www.jianshu.com/search?q='}, {title: '知乎', link: 'https://www.zhihu.com/search?type=content&q='}, {title: '维基百科', link: 'https://zh.wikipedia.org/wiki/'} ]; let div = $('<div id="zszen" class="小工具z" style="line-height:17px;overflow:hidden; position:fixed; right:2%; top:6%; z-index:9999;height: 25px; width: 53px;border:2px solid #dfdfdf;background-color:#ffffff"></div>'); $('body').append(div); let title = $('<h4 id="title" align="center" style="line-height:13px;margin-bottom:2px;margin-top:2px;line-height:1;padding-left:0px;padding-top:0px;-webkit-margin-before:.3em;-webkit-margin-after:.3em;-webkit-margin-start: 0px;-webkit-margin-end: 0px;font-weight: bold;"><font id="title" style="color:#336699;font-size:13">TOOLz</font></h4>'); div.append(title); let items = $('<div id="itemList" style="line-height:16px;text-align:center;align:center;padding-left:7px;padding-top:0px;color:#68ac10"/>');//<font style="font-size:12px;color:#68ac10">{{item.title}}</font> div.append(items); for(let info of infos){ // let btn = $('<input type="button" value="'+info.title+'" link="'+info.link+'" style="width:90%"/>'); let btn = $('<label style="width:105px;color:#333333;font-size:13px;line-height:0px;" link="'+info.link+'"><font>'+info.title+'</font></label><br>') btn.on('click',(evt)=>{ dealLink(evt, evt.currentTarget.getAttribute('link'),window.location.href); }) btn.on('mouseover',(evt)=>{ // evt.currentTarget evt.currentTarget.style.color = '#ff0000'; }) btn.on('mouseout',(evt)=>{ // dealLink(evt, evt.currentTarget.getAttribute('link'),window.location.href); evt.currentTarget.style.color = '#333333'; }) DLOG(info.title); items.append(btn); } let intro = $('<label id="tip" style="width:100%"><font style="margin:auto;text-align:center;padding-left:5px;color:#dddddd;font-size:11px;display:inline-block;">自动搜索关键字/选区</font></label>'); items.append(intro); div.on('mouseover',showList) div.on('mouseout',hideList) // hideList(); }, 1000) function showList(){ $('h4#title').children().html('小工具z'); $('div#zszen').css({width:'115px',height:'215px'}) $('div#zszen').find('font#title').css({'font-size':16}) $('div#zszen').find('div#itemList').show(); } function hideList(){ $('h4#title').children().html('TOOLz'); $('div#zszen').css({width:'53px',height:'25px'}) $('div#zszen').find('font#title').css({'font-size':13}) $('div#zszen').find('div#itemList').hide(); } function dealLink(evt,link,currentLink){ if(isDebug){ DLOG(link); return; } var str = currentLink; var keyword = ""; if(str.indexOf("www.baidu.com")!=-1){ console.log("百度:"); keyword = $('input.s_ipt').val(); }else if(str.indexOf("fanyi.baidu.com")!=-1){ keyword = $('textarea.textarea').val(); }else if(str.indexOf("bing.com")!=-1){ keyword = $('input.b_searchbox').val(); }else if(str.indexOf("www.google.com")!=-1){ keyword = $('input[role]').val(); }else if(str.indexOf("translate.google.com")!=-1 || str.indexOf("translate.google.cn")!=-1){ keyword = $('textarea#source').value; }else if(str.indexOf("taobao.com")!=-1){ keyword = $('input.search-combobox-input').val(); }else if(str.indexOf("jd.com")!=-1){ keyword = $('input.text#key').val(); }else if(str.indexOf("jianshu.com")!=-1){ keyword = $('input.search-input').val(); }else if(str.indexOf("zhihu.com")!=-1){ keyword = $('input.Input#Popover5-toggle').val(); }else if(str.indexOf("wikipedia.org")!=-1){ var str1 = window.location.href; var arr1 = str1.split("/"); keyword = arr1[arr1.length-1]; }else{ console.log("其他"); } if(getSelectedText()!=''){ keyword = getSelectedText(); } //console.log(evt) if(evt.shiftKey || evt.ctrlKey || evt.metaKey){ window.open(link+keyword,"_blank"); }else{ window.open(link+keyword,"_self"); } } function getSelectedText() { if (window.getSelection) { return window.getSelection().toString(); } else if (document.selection) { return document.selection.createRange().text; } return '' } function DLOG(...args){ if(isDebug) console.log.call(this,args); } // Your code here... })()