all-search
Version:
A top fixed menu that allows you to jump between various search engines, build based on Vue, and use rollup.
1,430 lines (1,427 loc) • 156 kB
JavaScript
// ==UserScript==
// @name all-search 全搜,搜索引擎快捷跳转,支持任意网站展示
// @version 1.3.17
// @description 2022-12-12更新 搜索辅助增强,任意跳转,无需代码适配,支持任意网站展示
// @author endday
// @license GPL-3.0-only
// @homepageURL https://github.com/endday/all-search
// @updateURL https://raw.github.com/endday/all-search/release/index.user.js
// @downloadURL https://raw.github.com/endday/all-search/release/index.user.js
// @supportURL
// @noframes
// @include *
// @require https://unpkg.com/vue@3.2.33/dist/vue.global.prod.js
// @require https://unpkg.com/all-search@1.3.17/lib/popper-lite.min.js
// @run-at document-idle
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
// @grant GM_getResourceText
// ==/UserScript==
(function() {
"use strict";
var name$1 = "all-search";
var version$1 = "1.3.17";
var keywords = [ "searchEngineJump", "tool", "tamperMonkey", "web", "javascript", "vue3" ];
var description = "A top fixed menu that allows you to jump between various search engines, build based on Vue, and use rollup.";
var author = "endday";
var homepage = "https://github.com/endday/all-search";
var license = "GPL-3.0-only";
var repository = {
type: "git",
url: "git@github.com:endday/all-search.git"
};
var files = [ "dist", "lib" ];
var unpkg = "dist/index.user.js";
var jsdelivr = "dist/index.user.js";
var packageManager = "pnpm@7.18.0";
var scripts = {
serve: "vue-cli-service serve --fix",
tmServe: "vue-cli-service serve --fix --tm",
build: "vue-cli-service build",
lint: "vue-cli-service lint",
pretmBuild: "npm run lint",
tmDev: "cross-env NODE_ENV=development rollup -c -w",
tmBuild: "cross-env NODE_ENV=production rollup -c",
prepare: "husky install"
};
var dependencies = {
"@element-plus/icons-vue": "^2.0.4",
"@popperjs/core": "^2.9.2",
axios: "^0.21.4",
"core-js": "^3.9.1",
"element-plus": "^2.2.22",
jsoneditor: "^9.9.0",
"resize-observer-polyfill": "^1.5.1",
vue: "^3.2.36",
"vue-draggable-next": "^2.0.1",
"vue-router": "^4.0.5"
};
var devDependencies = {
"@babel/eslint-parser": "^7.19.1",
"@commitlint/cli": "^17.1.2",
"@commitlint/config-conventional": "^17.1.0",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.0.3",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-replace": "^4.0.0",
"@rollup/plugin-terser": "^0.2.0",
"@vitejs/plugin-vue": "^2.3.3",
"@vue/cli-plugin-babel": "^5.0.0",
"@vue/cli-plugin-eslint": "^5.0.0",
"@vue/cli-service": "^5.0.0",
"@vue/compiler-sfc": "^3.0.7",
autoprefixer: "^10.4.7",
"babel-plugin-import": "^1.13.3",
"cross-env": "^7.0.3",
eslint: "^7.32.0",
"eslint-plugin-vue": "^7.7.0",
husky: "^8.0.1",
"lint-staged": "^13.1.0",
postcss: "^8.4.13",
rollup: "^2.72.1",
"rollup-plugin-delete": "^1.2.0",
"rollup-plugin-external-globals": "^0.6.1",
"rollup-plugin-styles": "^4.0.0",
sass: "^1.32.8",
"sass-loader": "^10.1.1",
vite: "^2.6.7"
};
var pkg = {
name: name$1,
version: version$1,
keywords: keywords,
description: description,
author: author,
homepage: homepage,
license: license,
repository: repository,
files: files,
unpkg: unpkg,
jsdelivr: jsdelivr,
packageManager: packageManager,
scripts: scripts,
"lint-staged": {
"*.{js,vue,ts,jsx,tsx}": [ "eslint --fix" ]
},
dependencies: dependencies,
devDependencies: devDependencies
};
Vue.reactive({
tmVersion: ""
});
const version = pkg.version;
function getQueryString(name, url) {
url = url || window.location.href;
const r = new RegExp("(\\?|#|&)" + name + "=([^&#]*)(&|#|$)");
const m = url.match(r);
return decodeURIComponent(!m ? "" : m[2]);
}
function checkBody() {
let time = 0;
return new Promise(((resolve, reject) => {
if (document && document.body) {
resolve();
} else {
const id = setInterval((function() {
time += 1;
if (document && document.body) {
clearInterval(id);
resolve();
}
if (time === 50) {
clearInterval(id);
reject(new Error("timeOut"));
}
}), 200);
if ([ "complete", "loaded", "interactive" ].includes(document.readyState)) {
if (document && document.body) {
clearInterval(id);
resolve();
}
} else {
document.addEventListener("DOMContentLoaded", (function() {
if (document && document.body) {
clearInterval(id);
resolve();
}
}));
}
}
}));
}
function getName(name) {
if (name) {
return `__allSearch__${name}`;
}
return null;
}
function isJson(str) {
if (typeof str !== "string") {
return false;
}
const char = str.charAt(0);
if (char !== "[" && char !== "{") {
return false;
}
try {
return typeof JSON.parse(str) === "object";
} catch (e) {
return false;
}
}
let getSession = function(name) {
const formatName = getName(name);
let item;
if (window.GM_getValue) {
item = window.GM_getValue(formatName);
} else {
item = window.localStorage.getItem(formatName);
}
if (item) {
if (isJson(item)) {
try {
return JSON.parse(item);
} catch (e) {
return item;
}
} else {
return item;
}
}
return null;
};
let setSession = function(name, value) {
const formatName = getName(name);
if (window.GM_setValue) {
window.GM_setValue(formatName, value);
} else {
const item = JSON.stringify(value);
if (item) {
window.localStorage.setItem(formatName, item);
}
}
};
function getAsRoot() {
return document.getElementById("all-search");
}
function createAsRoot() {
const el = document.createElement("div");
el.id = "all-search";
return el;
}
const scriptLoaded = getName("script-loaded");
const pageLoaded = getName("page-loaded");
function passTmMethods() {
const emit = function() {
document.dispatchEvent(new CustomEvent(scriptLoaded, {
detail: {
version: version,
getSession: getSession,
setSession: setSession
}
}));
};
document.addEventListener(pageLoaded, emit);
emit();
}
const isMobile = function() {
return /mobile|android|webos|iphone|ipod|blackberry|iphone os|ipad/i.test(navigator.userAgent);
};
function delAsDataSet(item) {
if (item.dataset) {
delete item.dataset.asMarginTop;
delete item.dataset.asTransform;
delete item.dataset.asBorderTop;
}
}
function getParent(el) {
let current = el;
let go = true;
while (go && current.offsetParent) {
if (current.offsetParent.tagName === "BODY") {
go = false;
} else {
current = current.offsetParent;
}
}
const style = window.getComputedStyle(current);
if (style.position !== "fixed") {
delAsDataSet(current);
return null;
}
return current;
}
function getRealFixedNode(item) {
if (!item || !isElement(item)) {
return null;
}
const style = window.getComputedStyle(item);
if (style.display === "none") {
return null;
} else if (style.position === "fixed") {
return item;
} else if (style.position === "absolute") {
return getParent(item);
} else {
return null;
}
}
function isElement(obj) {
return obj && obj instanceof Element && obj.nodeType === 1 && obj.tagName !== undefined;
}
function changeStyle(item) {
if (!item || !isElement(item)) {
return;
}
const style = window.getComputedStyle(item);
const styleMap = item.computedStyleMap && item.computedStyleMap();
const top = styleMap ? styleMap.get("top").value : null;
if (top === "auto") {
return;
} else if (style.top === "0px") {
item.style.top = "0px";
}
if (item.dataset.asMarginTop || item.dataset.asTransform || item.dataset.asBorderTop) {
return;
}
const marginTop = style.marginTop;
const transform = style.transform;
const transition = style.transition;
if (marginTop === "0px" && !transition.includes("margin")) {
item.dataset.asHasSet = "asMarginTop";
item.dataset.asMarginTop = "1";
} else if (transform === "none") {
item.dataset.asHasSet = "asTransform";
item.dataset.asTransform = "1";
} else {
item.dataset.asHasSet = "asBorderTop";
item.dataset.asBorderTop = "1";
}
}
let isSelfChange = false;
function getFixedNodeList(list, deep = false) {
const weakSet = new WeakSet;
const newList = [];
const nodes = list.filter((item => item)).map((item => {
delAsDataSet(item);
if (deep) {
Array.from(item.querySelectorAll("*")).map((item => {
delAsDataSet(item);
return getRealFixedNode(item);
})).filter((item => item)).forEach((item => {
if (!weakSet.has(item)) {
newList.push(item);
weakSet.add(item);
}
}));
}
return getRealFixedNode(item);
})).filter((item => item));
nodes.forEach((item => {
if (!weakSet.has(item)) {
newList.push(item);
weakSet.add(item);
}
}));
return newList;
}
function fixedDomPosition() {
checkBody().then((() => {
const nodes = Array.from(document.body.querySelectorAll("*")).filter((item => item.tagName !== "STYLE"));
getFixedNodeList(nodes).forEach((item => {
changeStyle(item);
}));
}));
}
function mutationObserver() {
const targetNode = document.body;
const config = {
attributes: true,
childList: true,
subtree: true,
attributeFilter: [ "style", "class" ]
};
const callback = function(mutationsList) {
if (isSelfChange) {
isSelfChange = false;
} else {
isSelfChange = true;
const root = getAsRoot();
const filterNodes = mutationsList.filter((mutation => mutation.type === "attributes" && [ "style", "class", "id" ].includes(mutation.attributeName) || mutation.type === "childList" && mutation.addedNodes.length && ![ "BODY", "STYLE" ].includes(mutation.target.tagName) && !root.contains(mutation.target))).map((mutation => mutation.target));
getFixedNodeList(filterNodes, true).forEach((item => {
changeStyle(item);
}));
}
};
const observer = new MutationObserver(callback);
observer.observe(targetNode, config);
}
function initSpecialStyle() {
fixedDomPosition();
mutationObserver();
}
function withHookBefore(originalFn, hookFn) {
return function() {
if (hookFn.apply(this, arguments) === false) {
return;
}
return originalFn.apply(this, arguments);
};
}
function withHookAfter(originalFn, hookFn) {
return function() {
const output = originalFn.apply(this, arguments);
hookFn.apply(this, arguments);
return output;
};
}
const protectStyle = function() {
if (Node.prototype.__as_hooks__) {
return;
}
Node.prototype.removeChild = withHookBefore(Node.prototype.removeChild, (e => {
if (e && e.tagName === "STYLE") {
return !(e.classList.contains("as-icon") || e.classList.contains("as-style") || e.classList.contains("elPopover") || e.classList.contains("elScrollbar"));
}
return true;
}));
Node.prototype.__as_hooks__ = true;
};
const changeBodyStyle = function(modeRef, remove = true) {
const mode = Vue.unref(modeRef);
const el = getAsRoot();
el.classList.remove("body-vertical", "body-horizontal");
if (!remove) {
el.classList.add(`body-${mode}`);
}
};
var search = [ {
nameZh: "百度",
url: "https://www.baidu.com/s?wd=%s&ie=utf-8"
}, {
nameZh: "谷歌",
url: "https://www.google.com/search?q=%s&ie=utf-8&oe=utf-8"
}, {
nameZh: "必应",
url: "https://cn.bing.com/search?q=%s"
}, {
nameZh: "DDG",
url: "https://duckduckgo.com/?q=%s"
}, {
nameZh: "头条搜索",
url: "https://so.toutiao.com/search?dvpf=pc&keyword=%s"
}, {
nameZh: "360",
url: "https://www.so.com/s?ie=utf-8&q=%s"
}, {
nameZh: "搜狗",
url: "https://www.sogou.com/web?query=%s"
}, {
nameZh: "Yandex",
url: "https://yandex.com/search/?text=%s"
} ];
var translate = [ {
nameZh: "百度翻译",
url: "http://fanyi.baidu.com/#auto/zh/%s"
}, {
nameZh: "DeepL",
url: "https://www.deepl.com/translator#zh/en/%s",
icon: "https://www.deepl.com/img/favicon/favicon_96.png"
}, {
nameZh: "谷歌翻译",
url: "https://translate.google.com/?q=%s"
}, {
nameZh: "有道词典",
url: "http://dict.youdao.com/search?q=%s",
icon: "https://shared.ydstatic.com/images/favicon.ico"
}, {
nameZh: "必应翻译",
url: "http://cn.bing.com/dict/search?q=%s"
} ];
var developer = [ {
nameZh: "开发者搜索",
url: "https://kaifa.baidu.com/searchPage?wd=%s&module=SEARCH"
}, {
nameZh: "MDN",
url: "https://developer.mozilla.org/zh-CN/search?q=%s"
}, {
nameZh: "stackoverflow",
url: "https://stackoverflow.com/search?q=%s"
}, {
nameZh: "掘金",
url: "https://juejin.cn/search?query=%s"
}, {
nameZh: "Can I Use",
url: "http://caniuse.com/#search=%s",
icon: "https://caniuse.com/img/favicon-128.png"
}, {
nameZh: "GitHub",
url: "https://github.com/search?utf8=✓&q=%s"
}, {
nameZh: "w3c",
url: "http://www.runoob.com/?s=%s"
}, {
nameZh: "GreasyFork",
url: "https://greasyfork.org/zh-CN/scripts?q=%s&utf8=✓",
icon: "https://greasyfork.org/packs/media/images/blacklogo96-b2384000fca45aa17e45eb417cbcbb59.png"
} ];
var video = [ {
nameZh: "bilibili",
url: "http://search.bilibili.com/all?keyword=%s"
}, {
nameZh: "腾讯视频",
url: "https://v.qq.com/x/search/?q=%s"
}, {
nameZh: "爱奇艺",
url: "http://so.iqiyi.com/so/q_%s",
icon: "https://www.iqiyi.com/favicon.ico"
}, {
nameZh: "youtube",
url: "https://www.youtube.com/results?search_query=%s"
}, {
nameZh: "优酷",
url: "http://www.soku.com/search_video/q_%s",
icon: "https://img.alicdn.com/tfs/TB1WeJ9Xrj1gK0jSZFuXXcrHpXa-195-195.png"
}, {
nameZh: "AcFun",
url: "https://www.acfun.cn/search?keyword=%s"
}, {
nameZh: "搜狐",
url: "http://so.tv.sohu.com/mts?wd=%s"
}, {
nameZh: "niconico",
url: "http://www.nicovideo.jp/search/%s"
} ];
var music = [ {
nameZh: "网易音乐",
url: "http://music.163.com/#/search/m/?s=%s",
icon: "https://s1.music.126.net/style/favicon.ico"
}, {
nameZh: "一听",
url: "http://so.1ting.com/all.do?q=%s"
}, {
nameZh: "QQ音乐",
url: "https://y.qq.com/portal/search.html#page=1&searchid=1&remoteplace=txt.yqq.top&t=song&w=%s"
}, {
nameZh: "百度音乐",
url: "http://music.baidu.com/search?ie=utf-8&oe=utf-8&key=%s"
}, {
nameZh: "酷我音乐",
url: "http://sou.kuwo.cn/ws/NSearch?type=all&key=%s"
}, {
nameZh: "酷狗",
url: "http://search.5sing.kugou.com/?keyword=%s"
} ];
var news = [ {
nameZh: "谷歌中文",
url: "https://news.google.com/search?q=%s&hl=zh-CN&gl=CN&ceid=CN:zh-Hans",
icon: "https://www.google.com/favicon.ico"
}, {
nameZh: "百度新闻",
url: "http://news.baidu.com/ns?word=%s&tn=news&from=news&cl=2&rn=20&ct=1",
icon: "https://www.baidu.com/favicon.ico"
}, {
nameZh: "网易-百度",
url: "https://www.baidu.com/s?wd=%s%20site%3Anews.163.com"
}, {
nameZh: "腾讯新闻",
url: "https://www.sogou.com/sogou?site=news.qq.com&query=%s"
}, {
nameZh: "凤凰新闻",
url: "https://so.ifeng.com/?q=%s&c=1"
}, {
nameZh: "CNN",
url: "https://edition.cnn.com/search/?q=%s"
}, {
nameZh: "BBC",
url: "https://www.bbc.co.uk/search?q=%s"
}, {
nameZh: "今日头条",
url: "https://www.toutiao.com/search/?keyword=%s"
} ];
var social = [ {
nameZh: "知乎",
url: "https://www.zhihu.com/search?q=%s&type=content"
}, {
nameZh: "推特",
url: "https://twitter.com/search/%s"
}, {
nameZh: "豆瓣",
url: "https://www.douban.com/search?source=suggest&q=%s"
}, {
nameZh: "百度贴吧",
url: "https://tieba.baidu.com/f?kw=%s&ie=utf-8"
}, {
nameZh: "新浪微博",
url: "https://s.weibo.com/weibo?q=%s"
}, {
nameZh: "脸书",
url: "https://www.facebook.com/search/results.php?q=%s"
}, {
nameZh: "微信搜索",
url: "http://weixin.sogou.com/weixin?ie=utf8&type=2&query=%s"
} ];
var knowledge = [ {
nameZh: "维基",
url: "http://zh.wikipedia.org/wiki/%s"
}, {
nameZh: "百度百科",
url: "http://baike.baidu.com/search/word?pic=1&sug=1&word=%s"
}, {
nameZh: "百度文库",
url: "http://wenku.baidu.com/search?word=%s&ie=utf-8"
}, {
nameZh: "豆丁文档",
url: "http://www.docin.com/search.do?searchcat=2&searchType_banner=p&nkey=%s"
}, {
nameZh: "爱问知识",
url: "http://iask.sina.com.cn/search?searchWord=%s"
}, {
nameZh: "萌娘百科",
url: "https://zh.moegirl.org.cn/index.php?search=%s",
icon: "https://zh.moegirl.org.cn/favicon.ico"
}, {
nameZh: "果壳",
url: "http://www.guokr.com/search/all/?wd=%s"
}, {
nameZh: "Quora",
url: "https://www.quora.com/search?q=%s"
} ];
var image = [ {
nameZh: "谷歌图片",
url: "https://www.google.com/search?q=%s&tbm=isch"
}, {
nameZh: "百度图片",
url: "http://image.baidu.com/search/index?tn=baiduimage&ie=utf-8&word=%s"
}, {
nameZh: "必应图片",
url: "https://www.bing.com/images/search?q=%s"
}, {
nameZh: "搜狗图片",
url: "https://pic.sogou.com/pics?query=%s"
}, {
nameZh: "pixiv",
url: "http://www.pixiv.net/search.php?word=%s"
}, {
nameZh: "flickr",
url: "http://www.flickr.com/search/?q=%s"
}, {
nameZh: "花瓣",
url: "http://huaban.com/search/?q=%s"
}, {
nameZh: "Pinterest",
url: "https://www.pinterest.com/search/pins/?q=%s&rs=typed&term_meta"
}, {
nameZh: "yandex",
url: "https://yandex.com/images/search?text=%s"
}, {
nameZh: "pixabay",
url: "https://pixabay.com/images/search/%s/",
icon: "https://pixabay.com/favicon-32x32.png"
}, {
nameZh: "unsplash",
url: "https://unsplash.com/s/photos/%s"
} ];
var shopping = [ {
nameZh: "淘宝",
url: "http://s.taobao.com/search?q=%s",
icon: "https://www.taobao.com/favicon.ico"
}, {
nameZh: "京东",
url: "http://search.jd.com/search?keyword=%s&enc=utf-8",
icon: "https://www.jd.com/favicon.ico"
}, {
nameZh: "苏宁",
url: "https://search.suning.com/%s/"
}, {
nameZh: "亚马逊",
url: "http://www.amazon.cn/s/ref=nb_sb_noss?field-keywords=%s",
icon: "https://www.amazon.cn/favicon.ico"
}, {
nameZh: "天猫",
url: "http://list.tmall.com/search_product.htm?q=%s"
}, {
nameZh: "值得买",
url: "http://search.smzdm.com/?c=home&s=%s"
}, {
nameZh: "当当网",
url: "http://search.dangdang.com/?key=%s"
}, {
nameZh: "1688",
url: "https://s.1688.com/selloffer/offer_search.htm?keywords=%s"
} ];
var disk = [ {
nameZh: "百度网盘",
url: "https://pan.baidu.com/disk/home?#/search?key=%s"
}, {
nameZh: "大力盘",
url: "https://www.dalipan.com/search?keyword=%s"
}, {
nameZh: "大圣盘",
url: "https://www.dashengpan.com/search?keyword=%s"
}, {
nameZh: "罗马盘",
url: "https://www.luomapan.com/search?keyword=%s"
}, {
nameZh: "小白盘",
url: "https://www.xiaobaipan.com/list-%s.html?from=1"
}, {
nameZh: "56网盘",
url: "https://www.56wangpan.com/search/kw%s"
} ];
const list$2 = [ {
nameZh: "搜索",
name: "search",
list: search
}, {
nameZh: "翻译",
name: "translate",
list: translate
}, {
nameZh: "视频",
name: "video",
list: video
}, {
nameZh: "购物",
name: "shopping",
list: shopping
}, {
nameZh: "音乐",
name: "music",
list: music
}, {
nameZh: "开发",
name: "developer",
list: developer
}, {
nameZh: "新闻",
name: "news",
list: news
}, {
nameZh: "社交",
name: "social",
list: social
}, {
nameZh: "百科",
name: "knowledge",
list: knowledge
}, {
nameZh: "图片",
name: "image",
list: image
}, {
nameZh: "网盘",
name: "disk",
list: disk
}, {
nameZh: "常用",
name: "personal",
list: []
} ].map((item => ({
...item,
data: {
visible: true
},
list: item.list.map((child => ({
...child,
data: {
visible: true
}
})))
})));
function initSites(type) {
let sitesData = list$2;
const localSites = getSession("sites");
if (localSites) {
sitesData = localSites;
}
if (type === "tm") {
sitesData = sitesData.filter((item => Array.isArray(item.list) && item.list.length > 0 && item.data && item.data.visible)).map((item => ({
...item,
show: false
})));
}
return sitesData;
}
const width = 100;
const list$1 = [ {
url: /\/\/www\.google\.com(.hk)?\/search/
}, {
url: /\/\/www\.baidu\.com\/(s|baidu)\?/
}, {
url: /\/\/[^.]*\.bing\.com\/search/
}, {
url: /\/\/duckduckgo\.com\/*/
}, {
url: /\/\/searx\.me\/\?q/
}, {
url: /\/\/www\.sogou\.com\/(?:web|s)/,
selectors: "#upquery"
}, {
url: /\/\/yandex\.com\/search/
}, {
url: /\/\/google\.infinitynewtab\.com\/\?q/
}, {
url: /\/\/baike\.baidu\.com\/item/
}, {
url: /\/\/baike\.baidu\.com\/search/
}, {
url: /\/\/wenku\.baidu\.com\/search/
}, {
url: /\/\/zhidao\.baidu\.com\/search/
}, {
url: /\/\/\D{2,5}\.wikipedia\.org\/wiki/
}, {
url: /\/\/www\.zhihu\.com\/search\?/
}, {
url: /\/\/www\.so\.com\/s/
}, {
url: /\/\/so\.baike\.com\/doc/
}, {
url: /\/\/www\.baike\.com\/wiki/
}, {
url: /\/\/www\.docin\.com\/search\.do/
}, {
url: /\/\/zhihu\.sogou\.com\/zhihu/,
selectors: "#upquery"
}, {
url: /\/\/weixin\.sogou\.com\/weixin\?/,
style: {
2: `.headsearch#scroll-header { left:unset; }`
}
}, {
url: /\/\/www\.quora\.com\/search\?/
}, {
url: /\/\/stackoverflow\.com\/search\?/,
style: {
2: `.top-bar._fixed { right: ${width}px }`
}
}, {
url: /\/\/search\.bilibili\.com\/all/,
selectors: ".search-input-el"
}, {
url: /\/\/www\.acfun\.cn\/search/,
selectors: ".search-text--standalone"
}, {
url: /\/\/www\.youtube\.com\/results/,
style: {
2: `ytd-app {margin-left:${width}px !important;}ytd-mini-guide-renderer.ytd-app, app-drawer{left:${width}px !important;}#masthead-container.ytd-app {width: calc(100% - 100px);}`
}
}, {
url: /\/\/www\.nicovideo\.jp\/search\//
}, {
url: /\/\/so\.iqiyi\.com\/so\/q/
}, {
url: /\/\/v\.qq\.com\/x\/search/
}, {
url: /\/\/music\.baidu\.com\/search/
}, {
url: /\/\/so\.1ting\.com\/all\.do/
}, {
url: /\/\/s\.music\.qq\.com/
}, {
url: /\/\/music\.163\.com\/.*?#\/search/
}, {
url: /\/\/image\.baidu\.com\/search/
}, {
url: /\/\/\w{2,10}\.google(?:\.\D{1,3}){1,2}\/[^?]+\?.*&tbm=isch/
}, {
url: /\/\/.*\.bing\.com\/images\/search/
}, {
url: /\/\/www\.flickr\.com\/search\//
}, {
url: /^http:\/\/www\.pixiv\.net\/search\.php/
}, {
url: /\/\/huaban\.com\/search\?/
}, {
url: /\/\/www\.pinterest\.com\/search\//
}, {
url: /\/\/thepiratebay\.org\/search/
}, {
url: /\/\/subhd\.tv\/search/
}, {
url: /\/\/translate\.google(?:\.\D{1,4}){1,2}/
}, {
url: /\/\/fanyi\.baidu\.com/
}, {
url: /\/\/.*\.bing\.com\/dict\/search\?q=/
}, {
url: /\/\/dict\.youdao\.com\/search/
}, {
url: /\/\/dict\.youdao\.com\/w/
}, {
url: /\/\/dict\.cn\/./
}, {
url: /\/\/s\.taobao\.com\/search/
}, {
url: /\/\/list\.tmall\.com\/search_product\.htm.*from=chaoshi/
}, {
url: /\/\/list\.tmall\.com\/search_product\.htm/
}, {
url: /\/\/search\.jd\.com\/search/
}, {
url: /\/\/search\.suning\.com/
}, {
url: /\/\/search\.smzdm\.com\/\?/
}, {
url: /\/\/s\.weibo\.com\/weibo\?q=/
}, {
url: /\/\/tieba\.baidu\.com\/f\/search/
}, {
url: /\/\/(movie|music|book)\.douban\.com\/subject_search?/
}, {
url: /\/\/www\.douban\.com\/search/
}, {
url: /\/\/xueshu\.baidu\.com\/(?:s|baidu)/,
style: {
2: `#left_menu_content { left: ${width}px !important;}`
}
}, {
url: /\/\/scholar\.google(?:\.\D{1,3}){1,2}\/scholar\?/
}, {
url: /\/\/github\.com\/search/
}, {
url: /\/\/www\.startpage\.com\/sp\/search/
}, {
url: /\/\/endday\.github\.io/,
invisible: true
}, {
url: /\/\/endday\.gitee\.io/,
invisible: true
} ];
const routerChange = cb => {
history.pushState = withHookAfter(history.pushState, cb);
history.replaceState = withHookAfter(history.replaceState, cb);
window.addEventListener("popstate", cb);
window.addEventListener("yt-navigate-finish", cb);
window.addEventListener("hashchange", cb);
};
let site = Vue.reactive(getSite());
function getMenuItem() {
let targetItem = null;
let urlObj = null;
const curItem = new URL(window.location.href);
initSites("tm").some((category => {
category.list.find((item => {
const menuItem = new URL(item.url);
if (menuItem.hostname === curItem.hostname && menuItem.pathname === curItem.pathname) {
targetItem = item;
urlObj = menuItem;
}
}));
}));
if (urlObj) {
for (const key of urlObj.searchParams.keys()) {
if (!curItem.searchParams.has(key)) {
targetItem = null;
}
}
}
return targetItem;
}
function getSite() {
const target = list$1.find((item => item.url.test(window.location.href.toLowerCase())));
const menuItem = getMenuItem();
if (target) {
return {
url: target.url,
invisible: !!target.invisible,
disabled: !!target.disabled,
style: target.style,
selectors: target.selectors,
query: target.query
};
} else if (menuItem) {
return {
url: menuItem.url,
invisible: false,
disabled: false,
style: menuItem.style,
selectors: menuItem.selectors,
query: menuItem.query
};
}
return {
url: "",
invisible: true,
disabled: true,
style: {},
selectors: null,
query: null
};
}
routerChange((() => {
const newSite = getSite();
Object.keys(site).forEach((key => {
site[key] = newSite[key] || "";
}));
}));
const isFullScreenRef = Vue.ref(false);
function isFullScreen() {
return document.fullscreen || document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement;
}
function onFullScreenChange(handler) {
const handleResize = function() {
if (!isFullScreen()) {
handler();
}
};
document.addEventListener("fullscreenchange", handler);
document.addEventListener("webkitfullscreenchange", handler);
document.addEventListener("mozfullscreenchange", handler);
document.addEventListener("MSFullscreenChange", handler);
document.addEventListener("resize", handleResize);
return () => {
document.removeEventListener("fullscreenchange", handler);
document.removeEventListener("webkitfullscreenchange", handler);
document.removeEventListener("mozfullscreenchange", handler);
document.removeEventListener("MSFullscreenChange", handler);
document.removeEventListener("resize", handleResize);
};
}
function useFullScreen() {
const removeListener = onFullScreenChange((() => {
isFullScreenRef.value = isFullScreen();
}));
Vue.onUnmounted((() => {
removeListener();
}));
return {
isFullScreen: isFullScreenRef
};
}
const session$3 = getSession("mode");
const getMode = val => {
if (![ "vertical", "horizontal" ].includes(val)) {
return "horizontal";
}
return val;
};
const modeRef = Vue.ref(getMode(session$3));
const mode = Vue.computed({
get: () => modeRef.value,
set: val => {
modeRef.value = val;
setSession("mode", getMode(val));
}
});
function useMode() {
return {
mode: mode
};
}
const options = new Map([ [ false, "关闭" ], [ "top", "向上" ], [ "bottom", "向下" ], [ "all", "滚动" ] ]);
const defaultOpt = {
show: true,
scrollHide: false
};
const session$2 = getSession("switchShow") || defaultOpt;
const getOpts = val => options.has(val) ? val : false;
const getOpt = val => Object.assign({}, defaultOpt, {
show: Boolean(val.show),
scrollHide: getOpts(val.scrollHide)
});
let data = Vue.reactive(getOpt(session$2));
const show = Vue.computed({
get: () => data.show,
set: val => {
data.show = val;
setSession("switchShow", data);
}
});
const scrollHide = Vue.computed({
get: () => data.scrollHide,
set: val => {
data.scrollHide = val;
setSession("switchShow", data);
}
});
function useSwitchShow() {
return {
show: show,
scrollHide: scrollHide,
options: options
};
}
class Raf {
constructor() {
this.init();
}
init() {
this._timerIdMap = {
timeout: {},
interval: {}
};
}
run(type = "interval", handler, interval = 16.7) {
const now = Date.now;
let stime = now();
let etime = stime;
const timerSymbol = Symbol("timerSymbol");
const loop = () => {
this.setIdMap(timerSymbol, type, loop);
etime = now();
if (etime - stime >= interval) {
if (type === "interval") {
stime = now();
etime = stime;
}
handler();
type === "timeout" && this.clearTimeout(timerSymbol);
}
};
this.setIdMap(timerSymbol, type, loop);
return timerSymbol;
}
setIdMap(timerSymbol, type, loop) {
this._timerIdMap[type][timerSymbol] = requestAnimationFrame(loop);
}
setTimeout(handler, timeout) {
return this.run("timeout", handler, timeout);
}
clearTimeout(timer) {
cancelAnimationFrame(this._timerIdMap.timeout[timer]);
}
setInterval(handler, timeout) {
return this.run("interval", handler, timeout);
}
clearInterval(timer) {
cancelAnimationFrame(this._timerIdMap.interval[timer]);
}
}
var raf = new Raf;
let id = null;
let styles = "";
function injectStyle(cssContent) {
styles += cssContent;
const styleNode = document.querySelector("#as-style-common");
if (styleNode) {
styleNode.styleSheet.cssText += styles;
styles = "";
} else if (!id) {
id = raf.setTimeout((() => {
const cssNode = document.createElement("style");
cssNode.setAttribute("type", "text/css");
cssNode.classList.add("as-style");
cssNode.id = "as-style-common";
cssNode.appendChild(document.createTextNode(styles));
styles = "";
const asRoot = document.getElementById("all-search");
const container = asRoot || document.body || document.head || document.documentElement || document;
container.appendChild(cssNode);
id = null;
}), 0);
}
}
var css$f = "#all-search .row, .all-search-config .row {\n display: flex;\n}\n#all-search .column, .all-search-config .column {\n display: flex;\n flex-direction: column;\n}\n#all-search .col, .all-search-config .col {\n flex: 1;\n}\n#all-search .row.items-center, #all-search .column.items-center, .all-search-config .row.items-center, .all-search-config .column.items-center {\n align-items: center;\n}\n#all-search .row.items-end, #all-search .column.items-end, .all-search-config .row.items-end, .all-search-config .column.items-end {\n align-items: flex-end;\n}\n#all-search .row.items-stretch, #all-search .column.items-stretch, .all-search-config .row.items-stretch, .all-search-config .column.items-stretch {\n align-items: stretch;\n}\n#all-search .row.justify-center, #all-search .column.justify-center, .all-search-config .row.justify-center, .all-search-config .column.justify-center {\n justify-content: center;\n}\n#all-search .row.justify-end, #all-search .column.justify-end, .all-search-config .row.justify-end, .all-search-config .column.justify-end {\n justify-content: flex-end;\n}\n#all-search .row.justify-between, #all-search .column.justify-between, .all-search-config .row.justify-between, .all-search-config .column.justify-between {\n justify-content: space-between;\n}\n#all-search .row.flex-wrap, .all-search-config .row.flex-wrap {\n flex-wrap: wrap;\n}\n#all-search .row.content-center, .all-search-config .row.content-center {\n align-content: center;\n}\n#all-search .row.content-end, .all-search-config .row.content-end {\n align-content: end;\n}\n\n@media screen and (max-width: 750px) {\n .as-title-horizontal {\n display: none;\n }\n}\n.as-title-horizontal {\n min-width: 90px;\n margin: 0 10px;\n}\n\n.as-title-vertical {\n width: 100%;\n}\n\n.as-title {\n text-decoration: none !important;\n padding: 0;\n margin: 0;\n color: var(--as-primary-color);\n}\n\n.as-title-inner {\n padding: 0;\n font-size: 17px;\n height: 30px;\n line-height: 30px;\n font-weight: 600;\n color: var(--as-primary-color);\n margin: 0 auto;\n text-align: center;\n cursor: pointer;\n}";
injectStyle(css$f);
var _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) {
target[key] = val;
}
return target;
};
const _sfc_main$g = {
name: "logo",
props: {
mode: {
type: String,
default: "horizontal",
validator: val => [ "horizontal", "vertical" ].indexOf(val) > -1
}
},
setup() {
return {
isMobile: isMobile()
};
}
};
const _hoisted_1$a = Vue.createElementVNode("p", {
class: "as-title-inner"
}, " All Search ", -1);
const _hoisted_2$7 = [ _hoisted_1$a ];
function _sfc_render$g(_ctx, _cache, $props, $setup, $data, $options) {
return !$setup.isMobile ? (Vue.openBlock(), Vue.createElementBlock("a", {
key: 0,
class: Vue.normalizeClass([ "as-title", `as-title-${$props.mode}` ]),
href: "https://github.com/endday/all-search",
target: "_blank"
}, _hoisted_2$7, 2)) : Vue.createCommentVNode("", true);
}
var logo = _export_sfc(_sfc_main$g, [ [ "render", _sfc_render$g ] ]);
var MapShim = function() {
if (typeof Map !== "undefined") {
return Map;
}
function getIndex(arr, key) {
var result = -1;
arr.some((function(entry, index) {
if (entry[0] === key) {
result = index;
return true;
}
return false;
}));
return result;
}
return function() {
function class_1() {
this.__entries__ = [];
}
Object.defineProperty(class_1.prototype, "size", {
get: function() {
return this.__entries__.length;
},
enumerable: true,
configurable: true
});
class_1.prototype.get = function(key) {
var index = getIndex(this.__entries__, key);
var entry = this.__entries__[index];
return entry && entry[1];
};
class_1.prototype.set = function(key, value) {
var index = getIndex(this.__entries__, key);
if (~index) {
this.__entries__[index][1] = value;
} else {
this.__entries__.push([ key, value ]);
}
};
class_1.prototype.delete = function(key) {
var entries = this.__entries__;
var index = getIndex(entries, key);
if (~index) {
entries.splice(index, 1);
}
};
class_1.prototype.has = function(key) {
return !!~getIndex(this.__entries__, key);
};
class_1.prototype.clear = function() {
this.__entries__.splice(0);
};
class_1.prototype.forEach = function(callback, ctx) {
if (ctx === void 0) {
ctx = null;
}
for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
var entry = _a[_i];
callback.call(ctx, entry[1], entry[0]);
}
};
return class_1;
}();
}();
var isBrowser = typeof window !== "undefined" && typeof document !== "undefined" && window.document === document;
var global$1 = function() {
if (typeof global !== "undefined" && global.Math === Math) {
return global;
}
if (typeof self !== "undefined" && self.Math === Math) {
return self;
}
if (typeof window !== "undefined" && window.Math === Math) {
return window;
}
return Function("return this")();
}();
var requestAnimationFrame$1 = function() {
if (typeof requestAnimationFrame === "function") {
return requestAnimationFrame.bind(global$1);
}
return function(callback) {
return setTimeout((function() {
return callback(Date.now());
}), 1e3 / 60);
};
}();
var trailingTimeout = 2;
function throttle$1(callback, delay) {
var leadingCall = false, trailingCall = false, lastCallTime = 0;
function resolvePending() {
if (leadingCall) {
leadingCall = false;
callback();
}
if (trailingCall) {
proxy();
}
}
function timeoutCallback() {
requestAnimationFrame$1(resolvePending);
}
function proxy() {
var timeStamp = Date.now();
if (leadingCall) {
if (timeStamp - lastCallTime < trailingTimeout) {
return;
}
trailingCall = true;
} else {
leadingCall = true;
trailingCall = false;
setTimeout(timeoutCallback, delay);
}
lastCallTime = timeStamp;
}
return proxy;
}
var REFRESH_DELAY = 20;
var transitionKeys = [ "top", "right", "bottom", "left", "width", "height", "size", "weight" ];
var mutationObserverSupported = typeof MutationObserver !== "undefined";
var ResizeObserverController = function() {
function ResizeObserverController() {
this.connected_ = false;
this.mutationEventsAdded_ = false;
this.mutationsObserver_ = null;
this.observers_ = [];
this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
this.refresh = throttle$1(this.refresh.bind(this), REFRESH_DELAY);
}
ResizeObserverController.prototype.addObserver = function(observer) {
if (!~this.observers_.indexOf(observer)) {
this.observers_.push(observer);
}
if (!this.connected_) {
this.connect_();
}
};
ResizeObserverController.prototype.removeObserver = function(observer) {
var observers = this.observers_;
var index = observers.indexOf(observer);
if (~index) {
observers.splice(index, 1);
}
if (!observers.length && this.connected_) {
this.disconnect_();
}
};
ResizeObserverController.prototype.refresh = function() {
var changesDetected = this.updateObservers_();
if (changesDetected) {
this.refresh();
}
};
ResizeObserverController.prototype.updateObservers_ = function() {
var activeObservers = this.observers_.filter((function(observer) {
return observer.gatherActive(), observer.hasActive();
}));
activeObservers.forEach((function(observer) {
return observer.broadcastActive();
}));
return activeObservers.length > 0;
};
ResizeObserverController.prototype.connect_ = function() {
if (!isBrowser || this.connected_) {
return;
}
document.addEventListener("transitionend", this.onTransitionEnd_);
window.addEventListener("resize", this.refresh);
if (mutationObserverSupported) {
this.mutationsObserver_ = new MutationObserver(this.refresh);
this.mutationsObserver_.observe(document, {
attributes: true,
childList: true,
characterData: true,
subtree: true
});
} else {
document.addEventListener("DOMSubtreeModified", this.refresh);
this.mutationEventsAdded_ = true;
}
this.connected_ = true;
};
ResizeObserverController.prototype.disconnect_ = function() {
if (!isBrowser || !this.connected_) {
return;
}
document.removeEventListener("transitionend", this.onTransitionEnd_);
window.removeEventListener("resize", this.refresh);
if (this.mutationsObserver_) {
this.mutationsObserver_.disconnect();
}
if (this.mutationEventsAdded_) {
document.removeEventListener("DOMSubtreeModified", this.refresh);
}
this.mutationsObserver_ = null;
this.mutationEventsAdded_ = false;
this.connected_ = false;
};
ResizeObserverController.prototype.onTransitionEnd_ = function(_a) {
var _b = _a.propertyName, propertyName = _b === void 0 ? "" : _b;
var isReflowProperty = transitionKeys.some((function(key) {
return !!~propertyName.indexOf(key);
}));
if (isReflowProperty) {
this.refresh();
}
};
ResizeObserverController.getInstance = function() {
if (!this.instance_) {
this.instance_ = new ResizeObserverController;
}
return this.instance_;
};
ResizeObserverController.instance_ = null;
return ResizeObserverController;
}();
var defineConfigurable = function(target, props) {
for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
var key = _a[_i];
Object.defineProperty(target, key, {
value: props[key],
enumerable: false,
writable: false,
configurable: true
});
}
return target;
};
var getWindowOf = function(target) {
var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
return ownerGlobal || global$1;
};
var emptyRect = createRectInit(0, 0, 0, 0);
function toFloat(value) {
return parseFloat(value) || 0;
}
function getBordersSize(styles) {
var positions = [];
for (var _i = 1; _i < arguments.length; _i++) {
positions[_i - 1] = arguments[_i];
}
return positions.reduce((function(size, position) {
var value = styles["border-" + position + "-width"];
return size + toFloat(value);
}), 0);
}
function getPaddings(styles) {
var positions = [ "top", "right", "bottom", "left" ];
var paddings = {};
for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
var position = positions_1[_i];
var value = styles["padding-" + position];
paddings[position] = toFloat(value);
}
return paddings;
}
function getSVGContentRect(target) {
var bbox = target.getBBox();
return createRectInit(0, 0, bbox.width, bbox.height);
}
function getHTMLElementContentRect(target) {
var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
if (!clientWidth && !clientHeight) {
return emptyRect;
}
var styles = getWindowOf(target).getComputedStyle(target);
var paddings = getPaddings(styles);
var horizPad = paddings.left + paddings.right;
var vertPad = paddings.top + paddings.bottom;
var width = toFloat(styles.width), height = toFloat(styles.height);
if (styles.boxSizing === "border-box") {
if (Math.round(width + horizPad) !== clientWidth) {