您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在右键菜单中,添加额外的搜索选项,选中文字后,点击右键,然后选择相应的搜索就可以直接跳转到对应的搜索、翻译、电商等平台。
当前为
// ==UserScript== // @name 右键搜索增强 // @namespace http://tampermonkey.net/ // @description 在右键菜单中,添加额外的搜索选项,选中文字后,点击右键,然后选择相应的搜索就可以直接跳转到对应的搜索、翻译、电商等平台。 // @version 1.0 // @author 桃源隐叟 // @include * // @grant GM_registerMenuCommand // @grant GM_openInTab // @run-at document-end // @match * // @homepageURL https://github.com/taoyuancun123/modifyText/blob/master/modifyText.js // @supportURL https://greasyfork.org/zh-CN/scripts/419894/feedback // @license GPLv3 // ==/UserScript== (function() { 'use strict'; var selection=''; //***********设置区域 */ var setting={ init:()=>{ document.body.insertAdjacentHTML("afterbegin",setting.settingHtml); document.body.querySelector("#tyc-close").onclick=()=>{ document.body.querySelector(".tyc-rc-container").style="display:none;"; } setting.insertItemToHtml(); }, settingHtml:` <style> .tyc-rc-container{ z-index:9999999999999999; display: block; width: 450px; height: auto; padding: 10px 5px; background: #fff; box-shadow: 0 1px 3px rgba(18,18,18,.1); border:1px solid rgba(18,18,18,.02); border-radius: 5px; position:fixed; right:50px; top:50px; } .tyc-rc-list{ display: flex; align-items: center; flex-direction: column; flex-wrap: nowrap; justify-content: center; align-content: center; margin: 5px 0px; border-top: 1px solid rgba(188,188,188,.1); padding-top: 5px; } .tyc-rc-item{ display: flex; align-items: center; flex-wrap: nowrap; justify-content: center; align-content: center; margin-bottom: 5px; } .tyc-rc-item input,.tyc-rc-item button{ margin: 0px 5px; } .tyc-rc-container button{ width: 50px; height: 30px; color: #563d7c; background-color: transparent; border-color: #563d7c; cursor: pointer; border: 1px solid; border-radius: 6px; } </style> <div class="tyc-rc-container"> <div> <button>新增</button> <button id="tyc-close" style="float: right;">X</button> </div> <div class="tyc-rc-list"></div> </div> `, searchItemHtml:`<div class="tyc-rc-item"> <input type="checkbox" name="sites" class="tyc-show-in-menu"> <label for="urls" class="tyc-search-tip">在知乎中搜索</label>- <input type="text" name="urls" placeholder="参考其他例子,输入除关键词外的网址部分" class="tyc-search-url"> <button class="tyc-control">删除</button> </div> `, searchItems:[ {title:"使用百度翻译",url:"https://fanyi.baidu.com/#zh/en/",show:true,index:0}, //{title:"google translate",url:"https://translate.google.cn/?sl=auto&tl=zh-CN&op=translate&text=",show:true,index:1}, {title:"search in google",url:"https://www.google.com/search?q=",show:true,index:2}, {title:"在知乎中搜索",url:"https://www.zhihu.com/search?type=content&q=",show:true,index:3} ], insertItemToHtml:()=>{ setting.searchItems.forEach((item) => { document.body.querySelector(".tyc-rc-list").insertAdjacentHTML("beforeend",setting.searchItemHtml); document.body.querySelector(".tyc-search-tip").innerText=item.title; document.body.querySelector(".tyc-search-url").value=item.url; //document.body.querySelector(".tyc-control").innerHTML= }); } } //设置区域结束 var addContextMenu={ registerMenu:()=>{ setting.searchItems.forEach((item) => { GM_registerMenuCommand(item.title,()=>{ let targetUrl=''; targetUrl=item.url+selection; GM_openInTab(targetUrl, {active:true}); }); }); }, } window.oncontextmenu=e=>{ selection=e.view.getSelection().toString(); } addContextMenu.registerMenu(); GM_registerMenuCommand('打开设置',setting.init); })();