您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
在网页右上角增加快捷搜索功能,功能如下:1.如果选择了文本,那么搜索文本,2.如果在百度,bing,谷歌,淘宝,京东,翻译等搜索框下,则搜索搜索框关键字。3.默认当前页面替换,单弹页面请按ctrl/shift/cmd键组合
当前为
// ==UserScript== // @name 搜索辅助小工具 - 淘宝,京东,百度,必应,谷歌,翻译等 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 在网页右上角增加快捷搜索功能,功能如下:1.如果选择了文本,那么搜索文本,2.如果在百度,bing,谷歌,淘宝,京东,翻译等搜索框下,则搜索搜索框关键字。3.默认当前页面替换,单弹页面请按ctrl/shift/cmd键组合 // @require https://unpkg.com/vue/dist/vue.js // @require https://cdn.staticfile.org/jquery/3.3.1/jquery.min.js // @author Zszen // @include http://* // @include https://* // @grant none // ==/UserScript== //let config_isHidden = localStorage.getItem("config_isHidden")==null? false:localStorage.getItem("config_isHidden"); (function () { 'use strict' setTimeout(function () { //console.log('config_isHidden',config_isHidden) let div = $('<div @mouseover="mouseover()" @mouseout="mouseout()" id="zszen" class="小工具z" v-bind:style="{height: heightVal, width: widthVal}" style="overflow:hidden; position:fixed; right:2%; top:6%; z-index:9999;width:115px;height:150px;border:2px solid #dfdfdf;background-color:#ffffff"></div>') $('body').append(div) let title = $('<h4 align="center" style="margin-bottom:0,margin-top:0;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;" @click="onClickTitle()"><font style="font-size:14px;color:#336699">{{title}}</font></h4>') div.append(title) let items = $('<li style="text-align:left; padding-left:10px;padding-top:0px;color:#68ac10" v-for="item,index in infos" :key="index"><a v-on:click="onClick($event,index)"><font style="font-size:12px;color:#68ac10">{{item.title}}</font></a>') div.append(items) // @ts-ignore let divApp = new Vue({ el: '#zszen', data: { title: '小工具z', hidden: true, widthVal:0, heightVal:0, 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='}, ] }, computed:{ isHidden:{ set:function(val){ //console.log(val) this.hidden = val; //config_isHidden = this.hidden; //localStorage.setItem("config_isHidden", config_isHidden); if(this.hidden){ this.heightVal = "30px"; this.widthVal = '60px'; }else{ this.heightVal = "170px"; this.widthVal = '115px'; } }, get:function(val){ return this.hidden; } } }, methods: { mouseover:function(){ this.isHidden = false; }, mouseout:function(){ this.isHidden = true; }, onClick: function (evt, val) { //window.location.href = this.infos[val].link var str = window.location.href; 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{ console.log("其他"); } if(getSelectedText()!=''){ keyword = getSelectedText(); } //console.log(evt) if(evt.shiftKey || evt.ctrlKey || evt.metaKey){ window.open(this.infos[val].link+keyword,"_blank"); }else{ window.open(this.infos[val].link+keyword,"_self"); } }, /*onClickTitle:function(){ //console.log('click', !this.isHidden) this.isHidden = !this.isHidden; }*/ } }); //divApp.isHidden = !(config_isHidden==null || config_isHidden==false); divApp.isHidden = true; }, 1000) function getSelectedText() { if (window.getSelection) { return window.getSelection().toString(); } else if (document.selection) { return document.selection.createRange().text; } return '' } // Your code here... })()