您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
✅快速切换搜索引擎,无需重复输入搜索
当前为
// ==UserScript== // @name 🚀🚀搜索助手🚀🚀 // @namespace http://baideye.com/ // @version 1.0.1 // @description ✅快速切换搜索引擎,无需重复输入搜索 // @author baideye // @match *://www.baidu.com/* // @match *://www.google.com/* // @match *://www.google.com.hk/* // @match *://cn.bing.com/* // @match *://www.sogou.com/* // @match *://duckduckgo.com/* // @match *://www.douyin.com/* // @match *://www.zhihu.com/* // @match *://search.bilibili.com/* // @match *://search.cnki.com.cn/* // @grant unsafeWindow // @grant window.onload // @grant GM_getValue // @grant GM_setValue // @run-at document-body // @license MIT // ==/UserScript== const searchInfo = [ { name: "百度", url: "https://www.baidu.com/s?wd=", regUrl: /www.baidu.com/i, mark: /bd/i, regWords: /wd=.*/i, isWords: function (str) { return str.toString().split("=")[1].split("&")[0]; }, }, { name: "谷歌", url: "https://www.google.com/search?q=", regUrl: /www.google.com/i, mark: /gg/i, regWords: /\?q=.*/i, isWords: function (str) { return str.toString().split("=")[1].split("&")[0]; }, }, { name: "必应", url: "https://cn.bing.com/search?q=", regUrl: /cn.bing.com/i, mark: /by/i, regWords: /\?q=.*/i, isWords: function (str) { return str.toString().split("=")[1].split("&")[0]; }, }, { name: "搜狗", url: "https://www.sogou.com/web?query=", regUrl: /www.sogou.com/i, mark: /sg/i, regWords: /query=.*/i, isWords: function (str) { return str.toString().split("=")[1].split("&")[0]; }, }, { name: "DDG", url: "https://duckduckgo.com/?q=", regUrl: /duckduckgo.com/i, mark: /ddg/i, regWords: /\?q=.*/i, isWords: function (str) { return str.toString().split("=")[1].split("&")[0]; }, }, { name: "抖音", url: "https://www.douyin.com/search/", regUrl: /www.douyin.com/i, mark: /dy/i, regWords: /search.*/i, isWords: function (str) { return str.toString().split("/")[1].split("?")[0]; }, }, { name: "知乎", url: "https://www.zhihu.com/search?q=", regUrl: /www.zhihu.com/i, mark: /zh/i, regWords: /\?q=.*/i, isWords: function (str) { return str.toString().split("=")[1].split("&")[0]; }, }, { name: "bilibili", url: "http://search.bilibili.com/all?keyword=", regUrl: /search.bilibili.com/i, mark: /blbl/i, regWords: /keyword=.*/i, isWords: function (str) { return str.toString().split("=")[1].split("&")[0]; }, }, ]; // 获取搜索词 // // let getWords = function () { // let url = window.location.href; // // console.log(ur);// // for (i = 0; i < searchInfo.length; i++) { // let search = searchInfo[i]; // if (search.regUrl.test(url)) { // console.log("regUrl匹配通过"); // let grep = search.regWords; // let str = url.match(grep); // // console.log(str)// // if (str === null) { // return ""; // } // let keyword = search.isWords(str); // // console.log(decodeURIComponent(keyword)); // // return decodeURIComponent(keyword); // } // } // } //添加浮窗 function addContent() { let oDiv = document.querySelector("body").appendChild(document.createElement("div")); oDiv.setAttribute("id", "contentBox"); oDiv.style = ` position:fixed; left:12px; top:160px; font-size:15px; color:#477493; background: #edf3f7; padding: 10px; border-radius: 5px; z-index:9999999; `; let oUl = oDiv.appendChild(document.createElement("ul")); oUl.style = ` display: flex; flex-direction: column; margin: 5px 2px 10px; `; for (var i = 0; i < searchInfo.length; i++) { var search = searchInfo[i]; if (search.mark.test(GM_getValue("setup_search"))) { var oLi = oUl.appendChild(document.createElement("li")); oLi.innerHTML = ` <a href='' id="url-a" style="color:#477493;" url='${search.url}'>${search.name}</a> `; oLi.style = ` list-style-type: none; margin: 3px 0; `; } } let divSet = oDiv.appendChild(document.createElement("div")); divSet.innerHTML = ` <svg width="20" height="20" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M34.0003 41L44 24L34.0003 7H14.0002L4 24L14.0002 41H34.0003Z" fill="none" stroke="#abcbe1" stroke-width="4" stroke-linejoin="round"/><path d="M24 29C26.7614 29 29 26.7614 29 24C29 21.2386 26.7614 19 24 19C21.2386 19 19 21.2386 19 24C19 26.7614 21.2386 29 24 29Z" fill="none" stroke="#abcbe1" stroke-width="4" stroke-linejoin="round"/></svg> `; divSet.onclick = function () { // let oDiv = document.querySelector("body").appendChild(document.createElement("div")); // let divBox = oDiv.appendChild(document.createElement("div")); // divBox.innerHTML += ` // <div> // <input type="text" value="${GM_getValue("setup_search")}"> // </div> // `; let sss = prompt("输入需要显示的搜索引擎,格式:bd-gg-by-sg-ddg-dy-zh-blbl"); if (sss) { GM_setValue("setup_search", sss); } console.log("用户设置" + GM_getValue("setup_search")); } } // ------------------------------------------------------ 'use strict'; //初始化设置 if (!GM_getValue("setup_search")) { GM_setValue("setup_search", "bd-gg-by-sg-ddg-dy-zh-blbl"); } //添加浮窗 addContent(); //监听<a> 点击添加搜索词 let aElement = document.querySelectorAll("#url-a"); for (let value of aElement) { value.addEventListener("click", function () { //获取搜索词 let nowUrl = window.location.href; let nowWords = ""; for (i = 0; i < searchInfo.length; i++) { let search = searchInfo[i]; if (search.regUrl.test(nowUrl)) { console.log("regUrl匹配通过"); let grep = search.regWords; let str = nowUrl.match(grep); // console.log(str)// if (str === null) { nowWords = ""; } else { var keyword = search.isWords(str); nowWords = decodeURIComponent(keyword);; } } } //添加 url = value.getAttribute("url"); value.setAttribute("href", url + nowWords); }); } console.log("当前存储的" + GM_getValue("setup_search"));
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址