// ==UserScript==
// @name 🚀🚀搜索助手🚀🚀
// @namespace http://baideye.com/
// @version 1.0.5
// @description ✅快速切换搜索引擎,无需重复输入
// @author 公众号:白的夜
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAYAAACtWK6eAAAAAXNSR0IArs4c6QAAGQtJREFUeF7tnQuUHGWVx/+3epJMV08iIaAuATUCu4iiCBpPSPCQ8BY2sGhiDkqYquq8WCYgLOCyBkfA3RUWxAQTMumqHhJdCUEBIUQ0GFaICIqwWYHsorzjK+ODzHT1JJmuu6cmGRLymu6vqnvqceucHM6hv3u/e3/3+09VV38PQoOuaXfz8Jae0mSNaCxBG+uxdzixNhbEYwH4/w5tUCjSTTwIbAawCUybmLxNGmlvMLxNHvOmnpbculXTaVsj0qB6dmIVyu/1tMoUDdp5APx/cgmBsAjc78G7X/MyP7bz2VfDcrqnn9AFkl9WOpEz2hkEbwqDTqtX4OJXCAwQIPBahvZjqng/LMzKPR0mmdAEYjjdx2rIzANwCQAtzCDFlxCokoAHYLGHypKiOfL5Km0O2CywQPLLyuPQRPOYPV8YuTCCEh9CICCBEpG2GH28pDAr+3IQX8oCaVv44ohS7rB/ISL/rnFIkCDEVgjUiUAXMy/JlX771UXzj96q0oeSQPLLy+O4jx0Ap6h0KjZCoMEEHqUmMgsza7+b1CwQ0y5PAvFdtOPVrFxCIBYEeMcr4xmOlX28loBrEkjecT/LwF21dCBthUCUCBAwo2DqK6uNqWqBmEX3CmLcUq1jaScEokqACVc6hn5rNfFVJRDTLltEXKjGobQRAnEgwEx5x8rag8U6qEBM251AhJ8O5kg+FwJxI8CMkxxLf+JAcR9QIK1LtxyTGdb0QtwSl3iFQLUEKtv7PtA5Z9TG/bXfr0DmLu9+5/ZK04/B/MFqO5N2QiB2BIieG5bpm3LHzJF/3Ffs+xRI+zpuev2V3vvAfE7sEpaAhUCtBIhWH/G+5vPbJ1Pfnqb7FIhpl64nogW19iPthUBcCTDzDY6Vu25QgfhzqzjDT8n0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qKpDdg2lbyCN6WkqnaERjCdpYj73DibWxIPYnQ/r/5BCfWquX7PabAWwC0yYmb5NG2hsMb5PHvKmlJ/foovnUkN1A/x+gCV8FfeGs1wAAAABJRU5ErkJggg==
// @match *://www.baidu.com/*
// @match *://www.google.com/*
// @match *://www.google.com.hk/*
// @match *://www.bing.com/*
// @match *://www.sogou.com/*
// @match *://duckduckgo.com/*
// @match *://yandex.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 deafultMark = "bd-gg-by-sg-ddg-yandex-dy-zh-blbl";
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://www.bing.com/search?q=",
regUrl: /www.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: "Yandex",
url: "https://yandex.com/search/?text=",
regUrl: /yandex.com/i,
mark: /yandex/i,
regWords: /\?text=.*/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];
},
},
];
//添加浮窗
function addContent() {
let oDiv = document.querySelector("body").appendChild(document.createElement("div"));
oDiv.setAttribute("id", "contentBox");
oDiv.style = `
position:fixed;
left:10px;
top:160px;
font-size:15px;
text-align: center;
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;
padding: 0px;
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;text-decoration: none;" url='${search.url}'>${search.name}</a>
`;
oLi.style = `
list-style-type: none;
margin: 3px 0;
`;
}
}
let divBtn = oDiv.appendChild(document.createElement("div"));
divBtn.style = `
display: flex;
justify-content: space-around;
align-items: center;
`;
divBtn.innerHTML = `
<span id="btnSet">
<svg width="17" height="17" 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>
</span>
<span id="btnClose">
<svg width="16" height="16" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44Z" fill="none" stroke="#abcbe1" stroke-width="4" stroke-linejoin="round"/><path d="M29.6567 18.3432L18.343 29.6569" stroke="#abcbe1" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/><path d="M18.3433 18.3432L29.657 29.6569" stroke="#abcbe1" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg>
</span>
`;
let btnSet = document.querySelector("#btnSet");
let btnClose = document.querySelector("#btnClose");
btnSet.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("输入需要显示的搜索引擎。格式:" + deafultMark);
if (sss) {
GM_setValue("setup_search", sss);
}
console.log("用户设置" + GM_getValue("setup_search"));
}
btnClose.onclick = function () {
oDiv.style = `display:none;`;
}
}
// ------------------------------------------------------
'use strict';
//初始化设置
if (!GM_getValue("setup_search")) {
GM_setValue("setup_search", deafultMark);
}
//添加浮窗
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);
});
value.addEventListener("contextmenu", 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"));