searchEngineJump-NextStage

方便的在各个引擎之间跳转。可自定义搜索列表的 NLF 修改版。

  1. // ==UserScript==
  2. // @name searchEngineJump-NextStage
  3. // @author ted423
  4. // @contributor NLF && ywzhaiqi
  5. // @description 方便的在各个引擎之间跳转。可自定义搜索列表的 NLF 修改版。
  6. // @version 10.2022.0605.0
  7. // @include *
  8. // @namespace https://github.com/ted423
  9. // @require https://code.jquery.com/jquery-3.3.1.min.js
  10. // @grant GM_getValue
  11. // @grant GM_setValue
  12. // @grant GM_addStyle
  13. // @grant GM_registerMenuCommand
  14. // @run-at document-start
  15. // ==/UserScript==
  16.  
  17.  
  18. (function() {
  19. "use strict";
  20. var prefs = {
  21. display: true,
  22. openInNewTab: true, //是否在新页面打开.
  23. engineListDataType: "ted423", //搜索列表默认类型
  24. debug: false
  25. };
  26. var svg ={
  27. list: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 511.626 511.626"><path d="M63.953 164.453H9.135c-2.474 0-4.615.9-6.423 2.709C.903 168.972 0 171.114 0 173.589v54.817c0 2.473.903 4.619 2.712 6.424 1.809 1.803 3.949 2.712 6.423 2.712h54.818c2.474 0 4.615-.905 6.423-2.712 1.809-1.809 2.712-3.951 2.712-6.424v-54.817c0-2.475-.904-4.617-2.712-6.427-1.808-1.806-3.949-2.709-6.423-2.709zM63.953 383.722H9.135c-2.474 0-4.615.896-6.423 2.707C.903 388.238 0 390.378 0 392.854v54.82c0 2.471.903 4.609 2.712 6.42 1.809 1.813 3.949 2.714 6.423 2.714h54.818c2.474 0 4.615-.903 6.423-2.714 1.809-1.807 2.712-3.949 2.712-6.42v-54.82c0-2.477-.904-4.616-2.712-6.426-1.808-1.803-3.949-2.706-6.423-2.706zM63.953 274.082H9.135c-2.474 0-4.615.91-6.423 2.714S0 280.749 0 283.22v54.815c0 2.478.903 4.62 2.712 6.427 1.809 1.808 3.949 2.707 6.423 2.707h54.818c2.474 0 4.615-.896 6.423-2.707 1.809-1.807 2.712-3.949 2.712-6.427V283.22c0-2.471-.904-4.613-2.712-6.424-1.808-1.807-3.949-2.714-6.423-2.714zM63.953 54.817H9.135c-2.474 0-4.615.903-6.423 2.712S0 61.479 0 63.953v54.817c0 2.475.903 4.615 2.712 6.424s3.949 2.712 6.423 2.712h54.818c2.474 0 4.615-.9 6.423-2.712 1.809-1.809 2.712-3.949 2.712-6.424V63.953c0-2.475-.904-4.615-2.712-6.424-1.808-1.804-3.949-2.712-6.423-2.712zM502.49 383.722H118.771c-2.474 0-4.615.896-6.423 2.707-1.809 1.81-2.712 3.949-2.712 6.426v54.82c0 2.471.903 4.609 2.712 6.42 1.809 1.813 3.946 2.714 6.423 2.714H502.49c2.478 0 4.616-.903 6.427-2.714 1.81-1.811 2.71-3.949 2.71-6.42v-54.82c0-2.477-.903-4.616-2.71-6.426-1.811-1.804-3.95-2.707-6.427-2.707zM502.49 274.082H118.771c-2.474 0-4.615.91-6.423 2.714s-2.712 3.953-2.712 6.424v54.815c0 2.478.903 4.62 2.712 6.427 1.809 1.808 3.946 2.707 6.423 2.707H502.49c2.478 0 4.616-.896 6.427-2.707 1.81-1.807 2.71-3.949 2.71-6.427V283.22c0-2.471-.903-4.613-2.71-6.424-1.811-1.804-3.95-2.714-6.427-2.714zM508.917 57.529c-1.811-1.805-3.949-2.712-6.427-2.712H118.771c-2.474 0-4.615.903-6.423 2.712s-2.712 3.949-2.712 6.424v54.817c0 2.475.903 4.615 2.712 6.424s3.946 2.712 6.423 2.712H502.49c2.478 0 4.616-.9 6.427-2.712 1.81-1.809 2.71-3.949 2.71-6.424V63.953c-.001-2.474-.904-4.615-2.71-6.424zM502.49 164.453H118.771c-2.474 0-4.615.9-6.423 2.709-1.809 1.81-2.712 3.952-2.712 6.427v54.817c0 2.473.903 4.615 2.712 6.424 1.809 1.803 3.946 2.712 6.423 2.712H502.49c2.478 0 4.616-.905 6.427-2.712 1.81-1.809 2.71-3.951 2.71-6.424v-54.817c0-2.475-.903-4.617-2.71-6.427-1.811-1.806-3.95-2.709-6.427-2.709z"/></svg>',
  28. setting: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 438.529 438.529"><path d="M436.25 181.438c-1.529-2.002-3.524-3.193-5.995-3.571l-52.249-7.992c-2.854-9.137-6.756-18.461-11.704-27.98 3.422-4.758 8.559-11.466 15.41-20.129 6.851-8.661 11.703-14.987 14.561-18.986 1.523-2.094 2.279-4.281 2.279-6.567 0-2.663-.66-4.755-1.998-6.28-6.848-9.708-22.552-25.885-47.106-48.536-2.275-1.903-4.661-2.854-7.132-2.854-2.857 0-5.14.855-6.854 2.567l-40.539 30.549c-7.806-3.999-16.371-7.52-25.693-10.565l-7.994-52.529c-.191-2.474-1.287-4.521-3.285-6.139C255.95.806 253.623 0 250.954 0h-63.38c-5.52 0-8.947 2.663-10.278 7.993-2.475 9.513-5.236 27.214-8.28 53.1-8.947 2.86-17.607 6.476-25.981 10.853l-39.399-30.549c-2.474-1.903-4.948-2.854-7.422-2.854-4.187 0-13.179 6.804-26.979 20.413-13.8 13.612-23.169 23.841-28.122 30.69-1.714 2.474-2.568 4.664-2.568 6.567 0 2.286.95 4.57 2.853 6.851 12.751 15.42 22.936 28.549 30.55 39.403-4.759 8.754-8.47 17.511-11.132 26.265l-53.105 7.992c-2.093.382-3.9 1.621-5.424 3.715C.76 182.531 0 184.722 0 187.002v63.383c0 2.478.76 4.709 2.284 6.708 1.524 1.998 3.521 3.195 5.996 3.572l52.25 7.71c2.663 9.325 6.564 18.743 11.704 28.257-3.424 4.761-8.563 11.468-15.415 20.129-6.851 8.665-11.709 14.989-14.561 18.986-1.525 2.102-2.285 4.285-2.285 6.57 0 2.471.666 4.658 1.997 6.561 7.423 10.284 23.125 26.272 47.109 47.969 2.095 2.094 4.475 3.138 7.137 3.138 2.857 0 5.236-.852 7.138-2.563l40.259-30.553c7.808 3.997 16.371 7.519 25.697 10.568l7.993 52.529c.193 2.471 1.287 4.518 3.283 6.14 1.997 1.622 4.331 2.423 6.995 2.423h63.38c5.53 0 8.952-2.662 10.287-7.994 2.471-9.514 5.229-27.213 8.274-53.098 8.946-2.858 17.607-6.476 25.981-10.855l39.402 30.84c2.663 1.712 5.141 2.563 7.42 2.563 4.186 0 13.131-6.752 26.833-20.27 13.709-13.511 23.13-23.79 28.264-30.837 1.711-1.902 2.569-4.09 2.569-6.561 0-2.478-.947-4.862-2.857-7.139-13.698-16.754-23.883-29.882-30.546-39.402 3.806-7.043 7.519-15.701 11.136-25.98l52.817-7.988c2.279-.383 4.189-1.622 5.708-3.716 1.523-2.098 2.279-4.288 2.279-6.571v-63.376c.005-2.474-.751-4.707-2.278-6.707zm-165.304 89.501c-14.271 14.277-31.497 21.416-51.676 21.416-20.177 0-37.401-7.139-51.678-21.416-14.272-14.271-21.411-31.498-21.411-51.673 0-20.177 7.135-37.401 21.411-51.678 14.277-14.272 31.504-21.411 51.678-21.411 20.179 0 37.406 7.139 51.676 21.411 14.274 14.277 21.413 31.501 21.413 51.678 0 20.175-7.138 37.403-21.413 51.673z"/></svg>'
  29. };
  30. var engineListData = {
  31. custom: "",
  32. ted423: "网页\n Google\n Google, https://www.google.com/search?q=%s&safe=off\n Google.hk, https://www.google.com.hk/search?q=%s&safe=off\n Google.co.jp,https://www.google.co.jp/search?q=%s&safe=off\n 百度, https://www.baidu.com/s?wd=%s\n 360, https://www.so.com/s?q=%s\n Bing\n Bing(CN), https://cn.bing.com/search?q=%s\n Bing(Global), https://global.bing.com/search?q=%s&setmkt=en-us&setlang=en-us\n 搜狗, https://www.sogou.com/web?query=%s\n DuckDuckGo, https://duckduckgo.com/?q=%s\n Yahoo\n Yahoo, https://search.yahoo.com/search?p=%s\n Yahoo(tw), https://tw.search.yahoo.com/search?p=%s\n Yahoo.co.jp, https://search.yahoo.co.jp/search?p=%s&aq=-1&x=wrt\n Startpage, https://www.startpage.com/do/search?q=%s\n资料\n Wiki\n ZWiki, https://zh.wikipedia.org/w/index.php?search=%s&button=&title=Special%3ASearch\n EWiki, https://en.wikipedia.org/w/index.php?search=%s&button=&title=Special%3ASearch\n JWiki, https://ja.wikipedia.org/w/index.php?search=%s&button=&title=Special%3ASearch\n 百度百科, https://baike.baidu.com/searchword/?word=%s\n Internet Archive, https://archive.org/search.php?query=%s\n Scholar, http://scholar.google.com/scholar?hl=zh-CN&q=%s&btnG=&lr=\n 百度学术, https://xueshu.baidu.com/s?wd=%s\n 知乎, https://www.zhihu.com/search?q=%s\n 萌娘百科, http://zh.moegirl.org/index.php?search=%s\n Google Book, https://www.google.com/search?q=%s&btnG=搜索图书&tbm=bks&tbo=1&hl=zh-CN&gws_rd=ssl\n 中国知网, https://kns.cnki.net/KNS8/DefaultResult/Index?dbcode=CFLS&kw=%s\n 爱学术, https://www.ixueshu.com/search/index.html?search_type=&q=%s\n 维普, http://lib.cqvip.com/Qikan/Search/Index?from=Qikan_Search_Index/%post#key=u%3D%s#indexKey=%s\n 开发\n stackoverflow, https://stackoverflow.com/search?q=%s\n MDN, https://developer.mozilla.org/en-US/search?q=%s\n github, https://github.com/search?q=%s\n krugle, http://opensearch.krugle.org/document/search/#query=%s\n npm, https://www.npmjs.org/search?q=%s\n地图\n 百度, http://map.baidu.com/?newmap=1&s=s%26wd%3D%s\n Google, https://www.google.com/maps/search/%s/\n Bing, https://www.bing.com/ditu/?q=%s\n 搜狗, https://map.sogou.com/#lq=%s\n音乐\n 千千, https://music.taihe.com/search?word=%s\n QQ, https://y.qq.com/portal/search.html#page=1&searchid=1&t=song&w=%s\n 一听, https://so.1ting.com/song?q=%s\n 虾米, http://www.xiami.com/search?key=%s\n piapro, https://piapro.jp/search/?view=audio&keyword=%s\n 刘志进, https://music.liuzhijin.cn/?name=%s&type=qq\n 歌词\n QQ歌词, https://y.qq.com/portal/search.html#page=1&searchid=1&t=lyric&w=%s\n 一听歌词, https://so.1ting.com/lyric?q=%s\n 歌词迷, http://gecimi.com/search/?keyword=%s\n图片\n 百度, http://image.baidu.com/search/index?tn=baiduimage&word=%s\n Google, https://www.google.com.hk/search?tbm=isch&q=%s\n 花瓣, https://huaban.com/search/?q=%s\n Picsearch, http://cn.picsearch.com/index.cgi?q=%s\n Flickr, https://www.flickr.com/search/?w=all&q=%s\n Pixiv, http://www.pixiv.net/search.php?s_mode=s_tag&word=%s\n dA, https://www.deviantart.com/browse/all/?q=%s\n下载\n BTDigg, https://btdig.com/search?q=%s\n idope, https://idope.se/torrent-list/%s\n TK, https://www.torrentkitty.tv/search/%s\n limetorrents\n co, https://www.limetorrents.co/search/all/%s\n asia, https://www.limetorrents.asia/search/all/%s\n pro, https://www.limetor.pro/search/all/%s\n ED2K\n xiaohx, https://v1.xiaohx.org/search?key=%s\n cdsoso, https://www.cdsoso.cc/searches-%s-hot-1-null.html\n 字幕\n zimuku, https://zimuku.org/search?q=%s&vertoken=d49cac93\n 射手网(伪), https://assrt.net/sub/?searchword=%s\n sub HD, https://subhd.la/search/%s\n Subscene, https://subscene.com/subtitles/searchbytitle%post#query=%s\n R3SUB, https://r3sub.com/search.php?s=%s\n影视\n torrentfunk2, https://www.torrentfunk2.com/all/torrents/%s.html?v=&smi=&sma=&i=250\n thepiratebay, https://thepiratebay.org/search/%s\n zooqle, https://zooqle.com/search?q=%s\n pianyuan, http://www.pianyuan.la/search?q=%s\n Torrentz2, https://www.torrentz2.xyz/?q=%s\n Torrentz2k, https://torrentz2k.xyz/search/%post#q=%s#category=all\n 1337x.to, https://www.1377x.to/search/%s/1/\n Torlock, https://www.torlock2.com/all/torrents/%s.html\n YourBT, https://yourbittorrent2.com/?q=%s\n TD, https://www.torrentdownloads.me/search/?search=%s\n xiaohx, https://www.xiaohx.org/search?key=%s\n RARBG\n rarbgprx, https://rarbgprx.org/torrents.php?search=%s\n rarbgproxy, https://rarbgproxy.org/torrents.php?search=%s\n kickass(镜像1), https://kat.sx/search.php?q=%s\n kickass(镜像2)\n kickasstorrents, https://kickasstorrents.to/usearch/%s\n kickass1.to, https://kickass1.to/usearch/%s/\n kat.am, https://kat.am/usearch/%s/\n kickasstorrent.cr, https://kickasstorrent.cr/usearch/%s/\nACG\n nyaa.si, https://nyaa.si/?f=0&c=0_0&q=%s\n dmhy, https://share.dmhy.org/topics/list?keyword=%s\n Tokyotosho, https://www.tokyotosho.info/search.php?terms=%s\n Mikan, http://mikanani.me/Home/Search?searchstr=%s\n *MioBT*, http://www.miobt.com/search.php?keyword=%s\n shana project, https://www.shanaproject.com/search/?title=%s\n 简单动漫, https://www.36dm.com/search.php?keyword=%s\n KOTOMI RSS, https://moe4sale.in/?kw=%s\n ACG狗狗, http://bt.acg.gg/search.php?keyword=%s\n ACG.RIP, https://acg.rip/?term=%s\n AcgnX, https://www.acgnx.se/search.php?sort_id=0&keyword=%s\n 末日動漫, https://share.acgnx.se/search.php?sort_id=0&keyword=%s\nSukebei\n nyaa.si, https://sukebei.nyaa.si/?f=0&c=0_0&q=%s\n Glodls, https://glodls.to/search_results.php?search=%s\n AniDex, https://anidex.info/?q=%s\n AcgnX Ero, https://www.anix.moe/search.php?sort_id=0&keyword=%s\n AniRena, https://www.anirena.com/?s=%s\n GGBases, http://www.ggbases.com/search.so?title=%s\n网购\n 一淘, https://www.etao.com/search.htm?nq=%s\n 京东, https://search.jd.com/Search?keyword=%s&enc=utf-8\n 淘宝, https://s.taobao.com/search?q=%s\n 亚马逊, https://www.amazon.cn/s/ref=nb_ss?keywords=%s\netc\n 邮编库, http://www.youbianku.com/%s\n AMO, https://addons.mozilla.org/zh-CN/firefox/search/?q=%s\n 汉典(字), http://www.zdic.net/sousuo/?q=%s&tp=tp1\n 汉典(词), http://www.zdic.net/sousuo/?q=%s&tp=tp3",
  33. };
  34.  
  35. var MAIN_CSS = "#sej-button{\n position: fixed;\n top: 0px;\n left: 0px;\n width: 14px;\n height: 14px;\n background: grey;\n border-radius: 7px !important;\n display: block;\n z-index: 91111111111;\n cursor: crosshair;\n}\n#sej-container{\n position:fixed;\n top:0px;\n z-index:91111111111;\n margin:0;\n background: white;\n box-shadow:0px 0px 3px #aaaaaa;\n margin:0 auto;\n display:table;\n font-family: Comic Sans MS, 'Microsoft YaHei', 微软雅黑;\n line-height: 1.5;\n font-size: 9px;\n transition: opacity 0.5s ease-in-out;\n}\nsejul{\n border: 1px solid #333;\n}\n#sej-container svg{\n height:15px;\n vertical-align: text-bottom;\n padding-right: 1px;\n}\n#sej-container button{\n font-size:9px;\n}\n\nsejul, sejli{\n margin: 0;\n padding: 0;\n list-style: none outside;\n}\nsejli{\n display: list-item;\n}\nsejli:hover>sejul{\n display:block;\n}\nbody>sejul>sejli{\n float: left;\n}\nsejli sejul{\n position: absolute;\n}\nsejli sejul sejul{\n margin-left: 100px;\n margin-top: -30px;\n}\nsejli sejul .sej-engine{\n padding: 4px 0px;\n width:100%;\n text-align: left;\n text-indent: 5px;\n}\n#sej-container>sejli{\n float: left;\n border-right: 1px solid #333;\n}\n#sej-container>sejli:last-child{\n border-right: none;\n}\n#sej-expanded-category{\n display: inline-block;\n font-weight: bold;\n padding: 0px 4px;\n line-height: 2;\n}\n#sej-expanded-category::after{\n content:' :';\n}\n.sej-engine{\n line-height: 2;\n display: inline-block;\n margin: 0;\n border: none;\n padding: 0px 4px;\n text-decoration: none;\n transition: background-color 0.15s ease-in-out;\n}\na.sej-engine{\n white-space: nowrap;\n min-width: 55px;\n text-align: center;\n}\nbutton.sej-engine{\n background-color: #FFFFFF;\n font-family: Comic Sans MS, 'Microsoft YaHei', 微软雅黑;\n color: #120886;\n cursor:pointer;\n}\na.sej-engine:visited, a.sej-engine:active{\n color: #120886;\n}\na.sej-engine:link, a.sej-engine:visited{\n text-decoration: none;\n}\n.sej-drop-list-trigger-shown{\n background-color: #DEEDFF !important;\n}\n.sej-drop-list-trigger::after {\n content:\'\';\n display: inline-block;\n margin: 0 0 0 3px;\n padding: 0;\n width: 0;\n height: 0;\n border-top: 6px solid #BCBCBC;\n border-right: 5px solid transparent;\n border-left: 5px solid transparent;\n border-bottom: 0px solid transparent;\n transition: -webkit-transform 0.3s ease-in-out;\n transition: transform 0.3s ease-in-out;\n vertical-align: unset;\n}\n.sej-drop-list-trigger-shown::after {\n -webkit-transform: rotate(180deg);\n transform: rotate(180deg);\n}\n.sej-engine:hover {\n background-color: #EAEAEA;\n}\n.sej-engine-icon {\n display: inline-block;\n height: 16px;\n border: none;\n padding: 0;\n margin: 0 3px 0 0;\n vertical-align: sub;\n}\n.sej-drop-list {\n display: none;\n float: left;\n min-width: 100px;\n font-size: 13px;\n -moz-box-shadow: 2px 2px 5px #ccc;\n -webkit-box-shadow: 2px 2px 5px #ccc;\n box-shadow: 2px 2px 5px #ccc;\n background-color: white;\n}\n.sej-drop-list> sejli {\n border-bottom: 1px solid #333;\n}\n.sej-drop-list> sejli:last-child {\n border-bottom: none;\n}";
  36.  
  37. var categoryMap = { //rules 和 engineList 的对应
  38. "web": "网页",
  39. "map": "地图",
  40. "video": "视频",
  41. "music": "音乐",
  42. "image": "图片",
  43. "Movie": "影视",
  44. "knowledge": "资料",
  45. "sociality": "社交",
  46. "shopping": "网购",
  47. "download": "下载",
  48. };
  49.  
  50. var engineListIntroduce = getMStr(function() {
  51. /*
  52. <div>
  53. <h2>分类规则:</h2>
  54. <i>【名称最好不要更改,类别跟站点规则有个对应关系】</i>
  55. <p>1、"音乐--music",代表类别是 "音乐"</p>
  56. </div>
  57. <div>
  58. <h2>搜索引擎规则:</h2>
  59. <code>名称,地址(%s 关键字)</code>
  60. <p>1、"//" 开头会被忽略</p>
  61. <p>2、中间分隔符:中文逗号(,) 或 英文逗号 + 空格(, )</p>
  62. <p>3、站点图标也可省略</p>
  63. <p>4、POST 范例 维普, http://lib.cqvip.com/Qikan/Search/Index?from=Qikan_Search_Index/%post#key=u%3D%s#indexKey=%s</p>
  64. </div>
  65. */
  66. });
  67.  
  68. function introduceToHtml() {
  69. return engineListIntroduce.replace(/((.*?))/g, "<span>$1</span>")
  70. .replace(/"(.*?)"/g, "<span>$1</span>");
  71. }
  72. function isTheSameCategory(c1, c2) {
  73. return (categoryMap[c1] || c1) == (categoryMap[c2] || c2);
  74. }
  75.  
  76. var rules = [ //根据规则把搜索引擎列表插入到指定网站
  77. {// 网页,第一个可以当模板看
  78. name: "google网页搜索", //你要加载的网站的名字(方便自己查找)
  79. url: /^https?:\/\/(encrypted\.google\.com|www\.google\.(?!co\.jp)[^\/]{2,9})\/(webhp|search|#|$|\?)(?!.*tbm=)/, //在哪个网站上加载,正则.
  80. mutationTitle: true, //mutationTitle监视标题的变化
  81. engineList: "web", //加载哪个类型的列表:
  82. // keyword 使用 css选中一个form input元素 或者 该项是一个函数,使用返回值
  83. // 插入文档,相关
  84. // target 将引擎跳转工具栏插入到文档的某个元素
  85. // (请使用css匹配,比如: "#subform_ctrl" );
  86. // where 四种:
  87. // "beforeBegin"(插入到给定元素的前面) ;
  88. // "afterBegin"(作为给定元素的第一个子元素) ;
  89. // "beforeEnd" (作为给定元素的最后一个子元素) ;
  90. // "afterEnd"(插入到给定元素的后面);.
  91. }, {
  92. name: "google.co.jp",
  93. url: /^https?:\/\/www\.google\.co\.jp\/(webhp|search|#|$|\?)(?:.(?!&tbm=))*$/,
  94. mutationTitle: true,
  95. engineList: "web",
  96. }, {
  97. name: "Startpage",
  98. url: /^https?:\/\/[a-z0-9]{3}\.startpage\.com\//,
  99. mutationTitle: true,
  100. engineList: "web",
  101. }, {
  102. name: "baidu 网页搜索", //因为不刷新搜索,所以百度跳简洁搜索会有问题
  103. url: /^https?:\/\/www\.baidu\.com\/(?:s.*|baidu.*|\?bn.*|\?tn.*|)$/,//bn、tn是推广之类的东西
  104. mutationTitle: true,
  105. engineList: "web",
  106. endFix: function() {
  107. if (getComputedStyle(document.getElementById("lg")).display != "none") remove();
  108. } //通过检测首页图片判断,在首页的话不显示
  109. }, {
  110. name: "bing(global)",
  111. url: /^https?:\/\/global\.bing\.com\/search/,
  112. engineList: "web",
  113. }, {
  114. name: "必应网页搜索",
  115. url: /^https?:\/\/(cn|www)\.bing\.com\/search/,
  116. engineList: "web",
  117. }, {
  118. name: "360搜索",
  119. url: /^https?:\/\/www\.so\.com\/s\?/,
  120. engineList: "web",
  121. }, {
  122. name: "搜狗网页搜索",
  123. url: /^https?:\/\/www\.sogou\.com\/(?:web|s)/,
  124. engineList: "web",
  125. keyword: "#upquery",
  126. }, {
  127. name: "雅虎网页搜索",
  128. url: /^https?:\/\/search\.yahoo\.com\/search/,
  129. change: "noExternalRequests",
  130. engineList: "网页",
  131. }, {
  132. name: "tw.yahoo",
  133. url: /^https?:\/\/tw\.search\.yahoo\.com\/search/,
  134. change: "noExternalRequests",
  135. engineList: "web",
  136. }, {
  137. name: "yahoo.co.jp",
  138. url: /^https?:\/\/search\.yahoo\.co\.jp\/search/,
  139. engineList: "web",
  140. }, {
  141. name: "duckduckgo",
  142. url: /^https?:\/\/duckduckgo\.com\/\?/,
  143. engineList: "web",
  144. },
  145. // 知识
  146. {
  147. name: "Scholar",
  148. url: /^https?:\/\/scholar\.google(?:\.\D{1,3}){1,2}\/scholar\?/,
  149. engineList: "资料",
  150. }, {
  151. name: "百度学术",
  152. url: /^https?:\/\/xueshu\.baidu\.com\/s\?/,
  153. engineList: "资料",
  154. }, {
  155. name: "IA",
  156. url: /^https?:\/\/archive\.org\/search\.php/,
  157. engineList: "资料",
  158. keyword: "input[type='text'][value]",
  159. }, {
  160. name: "百度百科",
  161. url: /^https?:\/\/baike\.baidu\.com\/(search|item)/,
  162. engineList: "资料",
  163. }, {
  164. name: "萌娘百科",
  165. url: /^https?:\/\/zh\.moegirl\.org\/./,
  166. engineList: "资料",
  167. keyword: function() {
  168. if (document.getElementById("searchText")) return document.querySelector("input[type='search']").value;
  169. else return document.getElementById("firstHeading").textContent;
  170. },
  171. }, {
  172. name: "Google book",
  173. url: /^https?:\/\/www\.google\.co.{1,3}\/search\?.*(&btnG=%E6)|(tbm=bks)/,
  174. mutationTitle: true,
  175. engineList: "资料",
  176. }, {
  177. name: "互动百科",
  178. url: /^https?:\/\/[a-z]{2,3}\.baike\.com\/[a-z]/,
  179. engineList: "资料",
  180. keyword: function() {
  181. var input;
  182. if (document.getElementsByClassName("ac_input")[0] != undefined) {
  183. if (document.getElementsByClassName("ac_input")[0].value != "")
  184. input = document.getElementsByClassName("ac_input")[0].value;
  185. else if (document.getElementsByClassName("blue")[0].innerHTML != "") input = document.getElementsByClassName("blue")[0].innerHTML;
  186. else input = document.evaluate("//h1", document, null, 9, null).singleNodeValue.innerHTML;
  187. } else if (document.getElementsByClassName("blue")[0].innerHTML != "") input = document.getElementsByClassName("blue")[0].innerHTML;
  188. else input = document.evaluate("//h1", document, null, 9, null).singleNodeValue.innerHTML;
  189. return input;
  190. },
  191. }, {
  192. name: "wiki",
  193. url: /^https?:\/\/..\.wikipedia\.org\/w\/index\.php(?!.*\?search=)/,
  194. engineList: "资料",
  195. }, {
  196. name: "wiki[ZH]",
  197. url: /^https?:\/\/zh\.wikipedia\.org\/(?:zh|wiki\/|w\/index.php\?search=)/,
  198. engineList: "资料",
  199. keyword: function() {
  200. if (document.getElementById("searchText"))return document.querySelector("#searchText>input").value;
  201. else return document.getElementById("firstHeading").childNodes[0].textContent;
  202. },
  203. }, {
  204. name: "wiki[EN]",
  205. url: /^https?:\/\/en\.wikipedia\.org\/(wiki\/|w\/index\.php\?search=)/,
  206. engineList: "资料",
  207. keyword: function() {
  208. if (document.getElementById("searchText"))
  209. return document.querySelector("#searchText>input").value;
  210. else return document.getElementById("firstHeading").childNodes[0].textContent;
  211. },
  212. }, {
  213. name: "wiki[JP]",
  214. url: /^https?:\/\/ja\.wikipedia\.org\/(wiki\/|w\/index\.php\?search=)/,
  215. engineList: "资料",
  216. keyword: function() {
  217. if (document.getElementById("searchText"))return document.querySelector("#searchText>input").value;
  218. else return document.getElementById("firstHeading").childNodes[0].textContent;
  219. },
  220. }, {
  221. name: "百度知道(search)",
  222. url: /^https?:\/\/zhidao\.baidu\.com\/search/,
  223. engineList: "资料",
  224. }, {
  225. name: "百度知道(search)",
  226. url: /^https?:\/\/zhidao\.baidu\.com\/search/,
  227. engineList: "资料",
  228. }, {
  229. name: "维普",
  230. url: /^https?:\/\/lib\.cqvip\.com\/Qikan/,
  231. engineList: "资料",
  232. }, {
  233. name: "爱学术",
  234. url: /^https?:\/\/www\.ixueshu\.com\/\search/,
  235. engineList: "资料",
  236. }, {
  237. name: "中国知网",
  238. url: /^https?:\/\/kns\.cnki\.net\/\KNS8\/DefaultResult/,
  239. engineList: "资料",
  240. }, {
  241. name: "知乎",
  242. url: /^https?:\/\/www\.zhihu\.com\/search\?/,
  243. change: "noExternalRequests",
  244. engineList: "资料",
  245. }, {
  246. name: "stackoverflow",
  247. url: /^https?:\/\/stackoverflow\.com\/search\?/,
  248. engineList: "资料",
  249. }, {
  250. name: "百度文库",
  251. url: /^https?:\/\/wenku\.baidu\.com\/search\?/,
  252. engineList: "资料",
  253. }, {
  254. name: "豆丁",
  255. url: /^https?:\/\/www\.docin\.com\/search\.do/,
  256. engineList: "资料",
  257. },
  258. // 地图
  259. {
  260. name: "百度地图",
  261. url: /^https?:\/\/map\.baidu\.com\/\?newmap/,
  262. engineList: "map",
  263. }, {
  264. name: "google地图",
  265. url: /^https?:\/\/www\.google\.co.{1,4}\/maps/,
  266. engineList: "map",
  267. mutationTitle: true,
  268. }, {
  269. name: "Bing地图",
  270. url: /^https?:\/\/[^.]*\.bing\.com\/ditu\//,
  271. engineList: "map",
  272. }, {
  273. name: "搜狗地图",
  274. url: /^https?:\/\/map\.sogou\.com\/#/,
  275. engineList: "map",
  276. },
  277. // 音乐
  278. {
  279. name: "千千音乐",
  280. url: /^https?:\/\/music\.taihe\.com\/search/,
  281. engineList: "music",
  282. keyword:".container input[valuekey]"
  283. }, {
  284. name: "QQ音乐",
  285. url: /^https?:\/\/y\.qq\.com\/portal\/search/,
  286. engineList: "music",
  287. keyword: ".search_input__input",
  288. }, {
  289. name: "音悦台",
  290. url: /^https?:\/\/so\.yinyuetai\.com\/mv\?/,
  291. engineList: "music",
  292. }, {
  293. name: "刘志进",
  294. url: /^https?:\/\/music\.liuzhijin\.cn\/\?name/,
  295. engineList: "music",
  296. }, {
  297. name: "一听音乐",
  298. url: /^https?:\/\/so\.1ting\.com\/(?!lyric)/,
  299. engineList: "music",
  300. etc: function() { //处理一听根据reffer拒绝访问的问题
  301. if (document.referrer.indexOf("https://so.1ting.com") == -1) {
  302. location.reload();
  303. }
  304. }
  305. }, {
  306. name: "一听歌词",
  307. url: /^https?:\/\/so\.1ting\.com\/lyric/,
  308. engineList: "music",
  309. etc: function() { //处理一听根据reffer拒绝访问的问题
  310. if (document.referrer.indexOf("https://so.1ting.com") == -1) {
  311. location.reload();
  312. }
  313. }
  314. }, {
  315. name: "歌词迷",
  316. url: /^https?:\/\/gecimi\.com\/search/,
  317. engineList: "music",
  318. keyword: function() {
  319. var key = location.href.split("keyword=")[1];
  320. return key;
  321. },
  322. }, {
  323. name: "xiami",
  324. url: /^https?:\/\/www\.xiami\.com\/search/,
  325. engineList: "music",
  326. keyword: function() {
  327. var key = location.href.split("key=")[1];
  328. return key;
  329. },
  330. },
  331. // 图片
  332. {
  333. name: "谷歌图片",
  334. url: /^https?:\/\/\w{2,10}\.google(?:\.\D{1,3}){1,2}\/search\?(.*tbs=sbi)|(.*tbm=isch)/,
  335. engineList: "image",
  336. }, {
  337. name: "百度图片",
  338. url: /^https?:\/\/image\.baidu\.c(om|n)\/search/,
  339. engineList: "image",
  340. style: "margin-left:35px"
  341. }, {
  342. name: "360图片",
  343. url: /^https?:\/\/\image\.so\.com\/i\?/,
  344. engineList: "image",
  345. }, {
  346. name: "bing图片",
  347. url: /^https?:\/\/.*\.bing\.com\/images\/search/,
  348. engineList: "image",
  349. }, {
  350. name: "搜狗图片",
  351. url: /^https?:\/\/pic\.sogou\.com\/pic/,
  352. engineList: "image",
  353. }, {
  354. name: "花瓣",
  355. url: /^https?:\/\/huaban\.com\/search\/\?/,
  356. engineList: "image",
  357. }, {
  358. name: "flickr",
  359. url: /^https?:\/\/www\.flickr\.com\/search/,
  360. change: "noExternalRequests",
  361. engineList: "image",
  362. keyword: function() {
  363. var input = document.querySelector("input[type='text'][value]");
  364. if (input) return input.value;
  365. else {
  366. var m = location.search.match(/q=([^&]+)/i);
  367. if (m) return true;
  368. }
  369. },
  370. }, {
  371. name: "picsearch",
  372. url: /^http:\/\/(..|...)\.picsearch\.com\/index\.cgi/,
  373. engineList: "image",
  374. }, {
  375. name: "pixiv",
  376. url: /^http:\/\/www\.pixiv\.net\/search\.php/,
  377. engineList: "image",
  378. keyword: "input[name=word]",
  379. }, {
  380. name: "deviantart",
  381. url: /^https?:\/\/www\.deviantart\.com\/browse\/all\//,
  382. engineList: "image",
  383. keyword: "#searchInput",
  384. etc: function() { //这个是为了调整编码
  385. if (window.location.href.indexOf("%26%23") == -1 && /%[A-Fa-f8-9][A-Fa-f0-9]/.test(window.location.href)) {
  386. var url = window.location.href.split("q=");
  387. window.location.href = url[0] + "q=" + toEscapeCharacter(decodeURIComponent(url[1]));
  388. }
  389. }
  390. },
  391. // 下载
  392. {
  393. name: "xiaohx",
  394. url: /^https?:\/\/www\.xiaohx\.org\/search\?/,
  395. engineList: "download",
  396. keyword:"input.search"
  397. }, {
  398. name: "xiaohx",
  399. url: /^https?:\/\/v1\.xiaohx\.org\/search\?/,
  400. engineList: "download",
  401. }, {
  402. name: "cdsoso",
  403. url: /^https?:\/\/www\.cdsoso\.cc\/searches/,
  404. engineList: "download",
  405. }, {
  406. name: "ed2000",
  407. url: /^https?:\/\/www\.ed2000\.com\/FileList\.asp/,
  408. engineList: "download",
  409. }, {
  410. name: "BTSOW",
  411. url: /^https?:\/\/btio\.pw\/search\//,
  412. engineList: "download",
  413. }, {
  414. name: "limetorrents",
  415. url: /^https?:\/\/www\.(limetorrents\.(info|asia|co)|limetor\.pro)\/search\//,
  416. engineList: "download",
  417. }, {
  418. name: "idope",
  419. url: /^https?:\/\/idope\.se\/torrent-list\//,
  420. engineList: "download",
  421. }, {
  422. name: "torrentkitty",
  423. url: /^https?:\/\/(www\.)?torrentkitty\.(net|org|tv)\/search\//,
  424. engineList: "download",
  425. keyword: function() {
  426. return document.getElementsByTagName("h2")[0].innerHTML.slice(18, -1);
  427. },
  428. },
  429. //影视
  430. {
  431. name: "thepiratebay",
  432. url: /^https?:\/\/thepiratebay\.org\/search/,
  433. engineList: "Movie",
  434. }, {
  435. name: "1337x",
  436. url: /^https?:\/\/www\.1377x\.to\/(sort-)?search/,
  437. engineList: "Movie",
  438. }, {
  439. name: "btdig",
  440. url: /^https?:\/\/(www\.)?btdig\.com\/search\?/,
  441. engineList: "download",
  442. }, {
  443. name: "kickass(替代)",
  444. url: /^https?:\/\/(kickass1\.to|kickasstorrent\.cr|kat\.am|kickasstorrents\.to)\/usearch\//,
  445. engineList: "Movie",
  446. keyword: function() {
  447. var key = document.querySelector("#contentSearch").value;
  448. if (key) return key;
  449. else key = document.title.split('"')[1];
  450. return key;
  451. },
  452. }, {
  453. name: "kickass(镜像1)",
  454. url: /^https?:\/\/kat\.sx\/u?search/,
  455. engineList: "Movie",
  456. }, {
  457. name: "RARBG",
  458. url: /^https?:\/\/(rarbgproxy\.org|rarbg\.is|rarbgprx\.org)\/torrents\.php\?search/,
  459. engineList: "Movie",
  460. }, {
  461. name: "yourbittorrent",
  462. url: /^https?:\/\/yourbittorrent2?\.com\/\?q/,
  463. engineList: "Movie",
  464. }, {
  465. name: "pianyuan",
  466. url: /^https?:\/\/www\.pianyuan\.la\/search\?q/,
  467. engineList: "Movie",
  468. }, {
  469. name: "torrentfunk2",
  470. url: /^https?:\/\/www\.torrentfunk2\.com\/[a-z]/,
  471. engineList: "download",
  472. }, {
  473. name: "idope",
  474. url: /^https?:\/\/zooqle\.com\/search\?/,
  475. engineList: "download",
  476. }, {
  477. name: "torlock",
  478. url: /^https?:\/\/www\.torlock2\.com\/[a-zA-Z]/,
  479. engineList: "Movie",
  480. keyword: function() {
  481. var key = document.title.split('Torrents')[0].replace('-',' ');
  482. return key;
  483. },
  484. }, {
  485. name: "torrent downloads",
  486. url: /^https?:\/\/www\.torrentdownloads\.me\/search\/\?search/,
  487. engineList: "Movie",
  488. keyword: "input[name='search']",
  489. }, {
  490. name: "extratorrent.si",
  491. url: /^https?:\/\/extratorrent\.si\/search\/\?search/,
  492. engineList: "Movie",
  493. }, {
  494. name: "Torrentz2",
  495. url: /^https?:\/\/(www\.)?torrentz2\.xyz\/\?q/,
  496. engineList: "download",
  497. }, {
  498. name: "Torrentz2k",
  499. url: /^https?:\/\/torrentz2k\.xyz\/search/,
  500. engineList: "download",
  501. },
  502. //ACG
  503. {
  504. name: "dmhy",
  505. url: /^https?:\/\/share\.dmhy\.org\/topics\/list/,
  506. engineList: "ACG",
  507. keyword: function() {
  508. var key = document.querySelector("#keyword").value;
  509. if (key) return key;
  510. else key = document.title.split(/「|」/)[1];
  511. return key;
  512. },
  513. }, {
  514. name: "Tokyotosho",
  515. url: /^https?:\/\/www\.tokyotosho\.info\/search\.php/,
  516. engineList: "ACG",
  517. }, {
  518. name: "*MioBT*",
  519. url: /^https?:\/\/www\.miobt\.com\/search\.php/,
  520. engineList: "ACG",
  521. keyword: "#topsearch",
  522. }, {
  523. name: "爱恋动漫",
  524. url: /^https?:\/\/www\.kisssub\.org\/search\.php/,
  525. engineList: "ACG",
  526. keyword: "#topsearch",
  527. }, {
  528. name: "Mikan",
  529. url: /^https?:\/\/mikanani\.me\/Home\/Search\?searchstr/,
  530. engineList: "ACG",
  531. }, {
  532. name: "acgsou",
  533. url: /^https?:\/\/www\.acgsou\.com\/search\.php/,
  534. engineList: "ACG",
  535. keyword: "#topsearch",
  536. }, {
  537. name: "36dm",
  538. url: /^https?:\/\/www\.36dm\.com\/search\.php/,
  539. engineList: "ACG",
  540. keyword: "#topsearch",
  541. }, {
  542. name: "KOTOMI RSS",
  543. url: /^https?:\/\/moe4sale\.in\/\?kw/,
  544. engineList: "ACG",
  545. }, {
  546. name: "ACG狗狗",
  547. url: /^https?:\/\/bt\.acg\.gg\/search/,
  548. engineList: "ACG",
  549. keyword: "#topsearch",
  550. }, {
  551. name: "ACG.RIP",
  552. url: /^https?:\/\/acg\.rip\/\?term/,
  553. engineList: "ACG",
  554. }, {
  555. name: "nyaa.si",
  556. url: /^https?:\/\/nyaa\.(si|uk)\/\?/,
  557. engineList: "ACG",
  558. }, {
  559. name: "Nyaapantsu",
  560. url: /^https?:\/\/(nyaa\.|www\.|)?(pantsu\.cat|nyaa\.pt)\/search\?/,
  561. engineList: "ACG",
  562. }, {
  563. name: "shana project",
  564. url: /^https?:\/\/www\.shanaproject\.com\/search/,
  565. engineList: "ACG",
  566. }, {
  567. name: "AcgnX",
  568. url: /^https?:\/\/www\.acgnx\.se\/search\.php\?/,
  569. engineList: "ACG",
  570. keyword: "#topsearch",
  571. }, {
  572. name: "末日动漫",
  573. url: /^https?:\/\/share\.acgnx\.se\/search\.php\?/,
  574. engineList: "ACG",
  575. keyword: "#topsearch",
  576. }, {
  577. name: "AniRena",
  578. url: /^https?:\/\/www\.anirena\.com\/\?s/,
  579. engineList: "ACG",
  580. },
  581. //Sukebei
  582. {
  583. name: "GGBases",
  584. url: /^https?:\/\/www\.ggbases\.com\/search/,
  585. engineList: "Sukebei",
  586. }, {
  587. name: "sukebei.nyaa.si",
  588. url: /^https?:\/\/sukebei\.nyaa\.(si|uk)\/\?/,
  589. engineList: "Sukebei",
  590. },{
  591. name: "Nayapantsu(sukebei)",
  592. url: /^https?:\/\/sukebei\.(pantsu\.cat|nyaa\.pt)\/search\?/,
  593. engineList: "Sukebei",
  594. }, {
  595. name: "anix",
  596. url: /^https?:\/\/www\.anix\.moe\/search\.php\?/,
  597. engineList: "Sukebei",
  598. keyword: "#topsearch",
  599. }, {
  600. name: "AniDex",
  601. url: /^https?:\/\/anidex\.info\/\?q/,
  602. engineList: "Sukebei",
  603. },
  604. //字幕
  605. {
  606. name: "subom",
  607. url: /^https?:\/\/www\.subom\.net\/search/,
  608. engineList: "download",
  609. }, {
  610. name: "subhd",
  611. url: /^https?:\/\/subhd\.tv\/search/,
  612. engineList: "download",
  613. keyword: "#sn",
  614. }, {
  615. name: "射手网(伪)",
  616. url: /^https?:\/\/assrt\.net\/sub\/\?s/,
  617. engineList: "download",
  618. }, {
  619. name: "Subscene",
  620. url: /^https?:\/\/subscene\.com\/subtitles\/searchbytitle/,
  621. engineList: "download",
  622. }, {
  623. name: "R3SUB",
  624. url: /^https?:\/\/r3sub\.com\/search\.php/,
  625. engineList: "download",
  626. },
  627. // 购物
  628. {
  629. name: "一淘",
  630. url: /^https?:\/\/www?\.etao\.com\/search/,
  631. engineList: "shopping",
  632. }, {
  633. name: "京东",
  634. url: /^https?:\/\/search\.jd\.com\/(S|s)earch\?/i,
  635. engineList: "shopping",
  636. }, {
  637. name: "淘宝搜索",
  638. url: /^https?:\/\/(s|haosou\.ai)\.taobao\.com\/search/,
  639. engineList: "shopping",
  640. }, {
  641. name: "易迅",
  642. url: /^https?:\/\/searchex\.yixun\.com\/html\?/,
  643. engineList: "shopping",
  644. }, {
  645. name: "苏宁",
  646. url: /^https?:\/\/search\.suning\.com\//,
  647. engineList: "shopping",
  648. }, {
  649. name: "天猫",
  650. url: /^https?:\/\/list\.tmall\.com\/\/?search/,
  651. engineList: "shopping",
  652. }, {
  653. name: "亚马逊",
  654. url: /^https?:\/\/www\.amazon\.cn\/s\/ref/,
  655. engineList: "shopping",
  656. }, {
  657. name: "当当",
  658. url: /^https?:\/\/search\.dangdang\.com\/\?key/,
  659. engineList: "shopping"
  660. }, {
  661. name: "newegg",
  662. url: /^https?:\/\/www\.newegg\.com\.tw\/search\?/,
  663. engineList: "shopping",
  664. keyword: "#searchword",
  665. },
  666. ];
  667.  
  668. function loadPrefs() {
  669. prefs.display = GM_getValue("display", prefs.display);
  670. prefs.openInNewTab = GM_getValue("openInNewTab", prefs.openInNewTab);
  671. prefs.debug = GM_getValue("debug", prefs.debug);
  672. prefs.engineListDataType = GM_getValue("engineListDataType", prefs.engineListDataType);
  673. engineListData.custom = GM_getValue("engineList") || "";
  674. reloadDebug();
  675. }
  676.  
  677. function openPrefs() {
  678. var d = document;
  679. var on = function(node, e, f) {
  680. node.addEventListener(e, f, false);
  681. };
  682.  
  683. var $ = function(s) {
  684. return d.getElementById("sej-prefs-" + s);
  685. };
  686. if ($("setup")) return;
  687.  
  688. var styleNode = GM_addStyle("\
  689. #sej-prefs-setup { position:fixed;z-index:2147483647;top:38px;right:60px;padding:20px 30px 10px;background:#eee;width:500px;border:1px solid black; }\
  690. #sej-prefs-setup * { color:black;text-align:left;line-height:normal;font-size:12px; }\
  691. #sej-prefs-setup i { 'Microsoft YaHei UI','微软雅黑',Arial; }\
  692. #sej-prefs-setup a { color:black;text-decoration:underline; }\
  693. #sej-prefs-setup div { text-align:center;font-size:14px; }\
  694. #sej-prefs-title { font-weight:bold; }\
  695. #sej-prefs-setup ul { margin:15px 0 0 0;padding:0;list-style:none;background:#eee;border:0; }\
  696. #sej-prefs-setup input, #sej-prefs-setup select { border:1px solid gray;padding:2px;background:white; height: auto; }\
  697. #sej-prefs-setup li { margin:0;padding:6px 0;vertical-align:middle;background:#eee;border:0 }\
  698. #sej-prefs-setup textarea { width:98%; height:60px; margin:3px 0; font-family: 'Microsoft YaHei UI','微软雅黑',Arial; }\
  699. #sej-prefs-setup button { padding: 1px 6px; font-size: 12px; margin-right: 3px; }\
  700. #sej-prefs-setup #top-buttons{text-align: left;}\
  701. #sej-prefs-setup img { display: initial; }\
  702. #sej-prefs-minitip { position: absolute; background: #ff9; border: 1px solid #F96; padding: 10px; left: -400px; top: 200px; right: 570px; }\
  703. #sej-prefs-minitip p { margin: 5px 5px; }\
  704. #sej-prefs-minitip span { color: green; }\
  705. #sej-prefs-debug { margin-left: 18px; }\
  706. ");
  707.  
  708. var div = d.createElement("div");
  709. div.id = "sej-prefs-setup";
  710. d.body.appendChild(div);
  711. div.innerHTML = "\
  712. <div id='top-buttons'>\
  713. <button id='sej-prefs-ok' title='立即生效'>√ 确定</button>\
  714. <button id='sej-prefs-cancel' title='取消本次设定,所有选项还原'>X 取消</button>\
  715. </div>\
  716. <div id='sej-prefs-title'>SearchEngineJumpCE 设置</div>\
  717. <ul>\
  718. <li>\
  719. <input type='checkbox' id='sej-prefs-openInNewTab' /> 在新页面打开\
  720. <input type='checkbox' id='sej-prefs-debug' /> 调试模式\
  721. </li>\
  722. <li>\
  723. 搜索列表版本:\
  724. <select id='sej-prefs-engineListDataType' >\
  725. <option value='custom'>用户版本</option>\
  726. <option value='ted423'>ted423版本</option>\
  727. </select>\
  728. <a style='margin-left: 20px;' target='_blank' href='https://gf.qytechs.cn/zh-CN/scripts/16193/feedback' title='通过反馈给作者加入你的版本'>加入你的版本?</a>\
  729. </li>\
  730. <li>自定义搜索列表:\
  731. <sej-i id='sej-prefs-engineList-tip'>(?)</sej-i>\
  732. <div>\
  733. <textarea id='sej-prefs-engineList' style='height: 350px;'></textarea>\
  734. </div>\
  735. </li>\
  736. </ul>\
  737. <div id='sej-prefs-minitip' style='display: none;'>" +
  738. introduceToHtml() + "\
  739. </div>\
  740. ";
  741. div = null;
  742.  
  743. var engineListType_sel = $("engineListDataType"),
  744. engineList_txt = $("engineList");
  745.  
  746. var close = function() {
  747. if (styleNode) {
  748. styleNode.parentNode.removeChild(styleNode);
  749. }
  750. var div = $("setup");
  751. div.parentNode.removeChild(div);
  752. };
  753.  
  754. on($("ok"), "click", function() {
  755. GM_setValue("openInNewTab", prefs.openInNewTab = !!$("openInNewTab").checked);
  756. GM_setValue("debug", prefs.debug = !!$("debug").checked);
  757. GM_setValue("engineListDataType", prefs.engineListDataType = engineListType_sel.value);
  758.  
  759. if (engineListType_sel.value == "custom") {
  760. GM_setValue("engineList", engineListData.custom = engineList_txt.value);
  761. }
  762.  
  763. // 刷新工具条
  764. remove();
  765. reloadDebug();
  766. debug("run");
  767. run();
  768. close();
  769. });
  770.  
  771. on($("cancel"), "click", close);
  772.  
  773. $("engineList-tip").onclick = function() {
  774. var minitip = $("minitip");
  775. minitip.style.display = (minitip.style.display == "block") ? "none" : "block";
  776. };
  777.  
  778. engineListType_sel.onchange = function() {
  779. engineList_txt.value = engineListData[engineListType_sel.value].trim();
  780. };
  781.  
  782. $("openInNewTab").checked = prefs.openInNewTab;
  783. $("debug").checked = prefs.debug;
  784. engineListType_sel.value = prefs.engineListDataType;
  785.  
  786. engineList_txt.value = engineListData[prefs.engineListDataType].trim();
  787. }
  788. // --------------------可设置项结束------------------------
  789. var debug;
  790.  
  791. function reloadDebug() {
  792. debug = prefs.debug ? console.log.bind(console) : function() {};//console.debug在chrome里失去作用
  793. }
  794.  
  795.  
  796. function getPostFormHTML(name, url, args, newTab) { //获取 method 为 POST 的表单的 HTML
  797. var form = "<form method='post'" +
  798. " action='" + url + "' id ='sej_" + name + "'" +
  799. (newTab ? " target='_blank'" : "") +
  800. ">";
  801. for (var arg in args) {
  802. var input = "<input type='hidden'" +
  803. " name='" + arg + "'" +
  804. " value='" + args[arg] + "'" +
  805. " />";
  806. form += input;
  807. }
  808. form += "</form>";
  809. return form;
  810. }
  811.  
  812. function wrapToHide(html) { //包装 HTML 元素代码以隐藏该元素
  813. return "<span style='display:none;'>" + html + "</span>";
  814. }
  815.  
  816. function toRE(obj) {
  817. if (obj instanceof RegExp) {
  818. return obj;
  819. } else if (obj instanceof Array) {
  820. return new RegExp(obj[0], obj[1]);
  821. } else {
  822. return new RegExp(obj);
  823. }
  824. }
  825.  
  826. function getMStr(func) {
  827. var lines = func.toString();
  828. lines = lines.substring(lines.indexOf("/*") + 3, lines.lastIndexOf("*/"));
  829. return lines;
  830. }
  831.  
  832. function toEscapeCharacter(str) { //dA使用ISO-8859-1编码,网页只能使用转义字符(UTF16)来显示其他字符 这里是对转义字符(UTF16)进行编码
  833. var length = str.length;
  834. var ret = [];
  835. var character;
  836. var charCode;
  837. var gCode;
  838. var neReg = /[\dA-z]/;
  839. for (var i = 0; i < length; i++) {
  840. charCode = str.charCodeAt(i);
  841. if (charCode <= 128) {
  842. character = str.charAt(i);
  843. if (neReg.test(character)) { /*ascii的数字字母不编码*/
  844. ret.push(character);
  845. } else ret.push("%" + charCode.toString(16));
  846. } else {
  847. gCode = charCode.toString();
  848. if (gCode) {
  849. while (gCode.length < 4) {
  850. gCode = "0" + gCode;
  851. }
  852. ret.push("%26%23" + gCode + "%3B");
  853. } else {
  854. /*字库里面没有.*/
  855. }
  856. }
  857. }
  858. return ret.join("");
  859. }
  860.  
  861. function getFaviconUrl(url, type) {
  862. var uri = parseUri(url);
  863. switch (type) {
  864. case 0:
  865. return "http://g.soz.im/" + uri.host;
  866. default:
  867. return uri.protocol + "://" + uri.host + "/favicon.ico";
  868. }
  869. }
  870.  
  871. // parseUri 1.2.2
  872. // (c) Steven Levithan <stevenlevithan.com>
  873. // MIT License
  874. var parseUri = function(str) {
  875. var o = parseUri.options,
  876. m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
  877. uri = {},
  878. i = 14;
  879.  
  880. while (i--) uri[o.key[i]] = m[i] || "";
  881.  
  882. uri[o.ds.name] = {};
  883. uri[o.ds.name][0] = {};
  884. uri[o.ds.name][0]["key"] = (uri.protocol ? uri.protocol : "http") + "://" + uri.host + (uri.port ? ":" + uri.port : "") + "/";
  885. uri[o.ds.name][0]["val"] = "/";
  886. i = 0;
  887. var tempsub = "/",
  888. subs = uri[o.key[10]].substr(1).split("/");
  889. for (var j = 1; j < (subs.length + 1); j++, i++) {
  890. tempsub += tempsub === "/" ? subs[i] : "/" + subs[i];
  891. if (subs[i]) {
  892. uri[o.ds.name][j] = {};
  893. uri[o.ds.name][j]["key"] = subs[i];
  894. uri[o.ds.name][j]["val"] = tempsub;
  895. }
  896. }
  897.  
  898. uri[o.q.name] = {};
  899. uri[o.key[12]].replace(o.q.parser, function($0, $1, $2) {
  900. if ($1) uri[o.q.name][$1] = $2;
  901. });
  902. uri[o.aq.name] = {};
  903. uri[o.key[13]].replace(o.aq.parser, function($0, $1, $2) {
  904. if ($1) uri[o.aq.name][$1] = $2;
  905. });
  906.  
  907. return uri;
  908. };
  909. parseUri.options = {
  910. strictMode: false,
  911. key: ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"],
  912. q: {
  913. name: "queryKey",
  914. parser: /(?:^|&)([^&=]*)=?([^&]*)/g
  915. },
  916. aq: {
  917. name: "anchorqueryKey",
  918. parser: /(?:^|&)([^&=]*)=?([^&]*)/g
  919. },
  920. ds: {
  921. name: "directorySub"
  922. },
  923. parser: {
  924. strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
  925. loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
  926. }
  927. };
  928.  
  929. function addGlobalStyle() {
  930. // 添加全局样式和自定义样式
  931. var style;
  932. if (!document.getElementById("sej-style")) {
  933. style = document.createElement("style");
  934. style.id = "sej-style";
  935. style.type = "text/css";
  936. style.textContent = MAIN_CSS + "\n" + (matchedRule.stylish || "");
  937. document.head.appendChild(style);
  938. if (prefs.display === false){
  939. style = document.createElement("style");
  940. style.id = "sej-display-style";
  941. style.type = "text/css";
  942. style.textContent = "#sej-container{pointer-events:none;opacity: 0.1;}";
  943. document.head.appendChild(style);
  944. }
  945. }
  946.  
  947. }
  948.  
  949. function addContainer(iTarget, iInput) {
  950. function parseDataStr(str) { //转换文本数据
  951. var List = str.split(/\n(?=[^\s])/);
  952. List.forEach(function(eachList) {
  953. var line = eachList.split(/[\n\r]+/);
  954. var category = line[0];
  955. category = category.split("--");
  956. if (isTheSameCategory(category[0], matchedRule.engineList)) {
  957. container.innerHTML += "<sejli><sejspan id='sej-expanded-category'>" + svg.list + category[0] + "</sejspan></sejli>";
  958. parseLine(container, line, true);
  959. } else {
  960. var contSejli = document.createElement("sejli");
  961. contSejli.innerHTML = "<sejspan class='sej-engine sej-drop-list-trigger'>"+ svg.list + category[0] + "</sejspan>";
  962. var sejul = document.createElement("sejul");
  963. sejul.className = "sej-drop-list";
  964. parseLine(sejul, line, false);
  965. contSejli.appendChild(sejul);
  966. container.appendChild(contSejli);
  967. }
  968. });
  969.  
  970.  
  971. //str = str.replace(/[\n\r]+[\s\/]*-\s*(\S+):/g, "_POST_ $1:"); //提前处理下特殊的 post 方式
  972.  
  973. function parseArgs(str) {
  974. var arr = str.split("#");
  975. var args = {};
  976. arr.forEach(function(s) {
  977. var argArr = s.split("=");
  978. args[argArr[0]] = argArr[1];
  979. });
  980. return args;
  981. };
  982.  
  983. function parseLine(container, line, isCurrent) {
  984. line.splice(0, 1);
  985. var sejul, defaultEngine, contSejli;
  986. var flag, flag2;
  987. for (var i = 0; i < line.length; i++) {
  988. if (!line[i]) continue;
  989.  
  990. if (line[i].indexOf("//") == 0) {
  991. continue;
  992. }
  993. var arr = line[i].replace(/,/g, ", ").split(/,\s/);
  994. if (isCurrent && matchedRule.engineList && toRE(matchedRule.url).test(arr[1])) { //去掉跳转到当前引擎
  995. if (flag == i - 1) flag++;
  996. if (flag2 == i - 1) {
  997. if (i == line.length - 1) {
  998. contSejli.appendChild(sejul);
  999. container.appendChild(contSejli);
  1000. }
  1001. flag2++;
  1002. }
  1003. continue;
  1004. }
  1005. var engine = {};
  1006. if (line[i].indexOf("%post") != -1) {
  1007. engine.method = "POST";
  1008. var two = line[i].split("%post#");
  1009. line[i] = two[0];
  1010. engine.args = parseArgs(two[1]);
  1011. }
  1012. if (arr.length === 1) { //分类
  1013. flag = i;
  1014. if (flag2 == i - 1 && sejul != "") {
  1015. contSejli.appendChild(sejul);
  1016. container.appendChild(contSejli);
  1017. }
  1018. defaultEngine = arr[0].trim();
  1019. sejul = document.createElement("sejul");
  1020. sejul.className = "sej-drop-list";
  1021. continue;
  1022. }
  1023. if (/\s\s/.test(arr[0])) { //引擎分类只支持2级,所以两个tab就是二级分类的引擎
  1024. var sejli = document.createElement("sejli");
  1025. sejli.innerHTML = getaPattern(arr,engine);
  1026. sejul.appendChild(sejli);
  1027. if (i == flag + 1) { //由于二级分类大多是引擎细分,所以引擎名字上也需要能点击才行
  1028. arr[0] = defaultEngine;
  1029. contSejli = document.createElement("sejli");
  1030. contSejli.innerHTML = getaPattern(arr,engine).replace("sej-engine", "sej-engine sej-drop-list-trigger");
  1031. }
  1032. flag2 = i; //flag2代表二级分类的引擎标记,结束后需要写入列表
  1033. if (i == line.length - 1) { //如果已二级分类的引擎结尾,写入列表
  1034. contSejli.appendChild(sejul);
  1035. container.appendChild(contSejli);
  1036. }
  1037. continue;
  1038. }
  1039. if (/\s[^\s]/.test(arr[0])) {
  1040. if (flag2 == i - 1 && sejul != "") { //看是否二级分类引擎结束
  1041. contSejli.appendChild(sejul);
  1042. container.appendChild(contSejli);
  1043. }
  1044. sejul = "";
  1045. sejli = document.createElement("sejli");
  1046. sejli.innerHTML = getaPattern(arr,engine);
  1047. container.appendChild(sejli);
  1048. }
  1049. }
  1050. }
  1051.  
  1052. }
  1053.  
  1054. function getaPattern(arr,engine) {
  1055. engine.name = arr[0].trim();
  1056. engine.url = arr[1];
  1057. if(engine.method == "POST") engine.url = engine.url.split("%post")[0];
  1058. engine.host = parseUri(engine.url).host;
  1059. if (arr[2]) engine.favicon = arr[2];
  1060. var a = aPattern.replace("$url$", engine.url)
  1061. .replace("$name$", engine.name)
  1062. .replace("$title$", engine.name);
  1063. if (engine.favicon) {
  1064. if (/^fa/.test(engine.favicon)) a = a.replace("<img src='$favicon$' class='sej-engine-icon' />", "<sej-i class='fa " + engine.favicon + "'></sej-i>");
  1065. a = a.replace("$favicon$", engine.favicon);
  1066. } else {
  1067. a = a.replace("src='$favicon$'", "");
  1068. }
  1069.  
  1070. if (engine.method && engine.method.toUpperCase() == "POST") {
  1071. var f = wrapToHide(getPostFormHTML(engine.name, engine.url, engine.args, prefs.openInNewTab));
  1072. a = a.replace("$form$", f);
  1073. a = a.replace("a href=''","button type='submit' value='Submit'" + "form='sej_"+ engine.name + "'" );
  1074. } else {
  1075. a = a.replace("$form$", "");
  1076. }
  1077. return a;
  1078. }
  1079. // 创建dom
  1080. var aPattern = "<a href='' class='sej-engine'" + (prefs.openInNewTab ? " target='_blank' " : " ") +
  1081. "url='$url$' _title='$title$'>" +
  1082. "<img src='$favicon$' class='sej-engine-icon' />$form$<span>$name$</span></a>";
  1083.  
  1084. var container = document.createElement("sejul");
  1085. container.id = "sej-container";
  1086.  
  1087. container.addEventListener("mousedown", mousedownhandler, true);
  1088. if (matchedRule.style) {
  1089. container.style.cssText = matchedRule.style;
  1090. }
  1091. // 根据搜索列表的类型得到数据
  1092. var engineListDataStr = engineListData[prefs.engineListDataType] || engineListData.normal;
  1093. parseDataStr(engineListDataStr);
  1094. var insertWhere = matchedRule.insertIntoDoc ? matchedRule.insertIntoDoc.where : "beforeBegin"; //设置插入的位置
  1095. var sejButton = document.getElementById("sej-button");
  1096.  
  1097. if (!sejButton) {} else if (sejButton) {
  1098. sejButton.parentNode.removeChild(sejButton);
  1099. }
  1100.  
  1101. var button = document.createElement("sejdiv");
  1102. button.id = "sej-button";
  1103. button.onmouseover = function() {
  1104. if ($("#sej-container").css("pointer-events") === "none") {
  1105. $("#sej-container").css("pointer-events", "all").css("opacity", "1");
  1106. GM_setValue("display", true);
  1107. } else {
  1108. $("#sej-container").css("pointer-events", "none").css("opacity", "0.1");
  1109. GM_setValue("display", false);
  1110. }
  1111. }
  1112. document.head.parentNode.insertBefore(button,document.head);
  1113. //设置按钮
  1114. var configBtn = document.createElement("sej-li");
  1115. configBtn.innerHTML = "<sejspan class='sej-engine'>" + svg.setting + "</sejspan>";
  1116. configBtn.onclick = openPrefs;
  1117. container.appendChild(configBtn);
  1118.  
  1119. switch (insertWhere.toLowerCase()) { //插入到文档中
  1120. case "beforebegin":
  1121. iTarget.parentNode.insertBefore(container, iTarget);
  1122. break;
  1123. case "afterbegin":
  1124. if (iTarget.firstChild) {
  1125. iTarget.insertBefore(container, iTarget.firstChild);
  1126. } else {
  1127. iTarget.appendChild(container);
  1128. }
  1129. break;
  1130. case "beforeend":
  1131. iTarget.appendChild(container);
  1132. break;
  1133. case "afterend":
  1134. if (iTarget.nextSibling) {
  1135. iTarget.parentNode.insertBefore(container, iTarget.nextSibling);
  1136. } else {
  1137. iTarget.parentNode.appendChild(container);
  1138. }
  1139. break;
  1140. }
  1141.  
  1142. if (typeof matchedRule.endFix == "function") {
  1143. try {
  1144. matchedRule.endFix();
  1145. } catch (ex) {
  1146. console.error("endFix 错误", ex);
  1147. }
  1148. }
  1149.  
  1150. function mousedownhandler(e) {
  1151. var target = e.target;
  1152. if (!target.href) target = target.parentNode;
  1153. if (!target || target.className.indexOf("sej-engine") == -1) return;
  1154. if (!target || !this.contains(target)) return;
  1155. var value;
  1156. if (typeof iInput == "function") value = iInput();
  1157. else {
  1158. if (iInput.nodeName == "INPUT" || iInput.localName == "textarea") value = iInput.value;
  1159. else value = iInput.textContent;
  1160. }
  1161. if (document.characterSet != "UTF-8") value = encodeURIComponent(value);
  1162. // 根据后代元素中是否存在 form 元素,判断提交方式并进行处理
  1163. // 如果没有 form 元素,将会使用 GET 方法提交;如果有,将会使用 POST 方法提交
  1164. var forms = target.getElementsByTagName("form");
  1165. if (forms.length == 0) { //提交方式为 GET
  1166. value = value.replace("&","%26");//&直接提交到地址栏中无法搜索,可能还有其他特殊符号也需要类似处理。只在get
  1167. value = value.replace("#","%23");
  1168. target.href = target.getAttribute("url").replace(/%s/g, value); //替换"全部"关键词
  1169. } else { //提交方式为 POST
  1170. var inputs = target.getElementsByTagName("input");
  1171. for (var i = 0; i < inputs.length; i++) inputs[i].value = inputs[i].value.replace(/%s/g, value); //// 替换"全部"关键词
  1172. }
  1173. }
  1174. }
  1175.  
  1176. function run() {
  1177. // 百度搜索插入到顶部搜索条下面就会造成页面部分元素的消失,所以需要每个部分都判断下是否存在
  1178. // 判断插入位置和输入框是否存在
  1179. var iTarget = matchedRule.insertIntoDoc ? document.querySelector(matchedRule.insertIntoDoc.target) : document.querySelector("head");
  1180. var iInput;
  1181. if (matchedRule.keyword) {
  1182. if (typeof matchedRule.keyword == "function") {
  1183. iInput = matchedRule.keyword;
  1184. if (!iInput()) {
  1185. return;
  1186. }
  1187. } else {
  1188. iInput = document.querySelector(matchedRule.keyword);
  1189. }
  1190. } else {
  1191. iInput = document.querySelector("input[type='search'],input[type='text'][autocomplete='off'],input[autocomplete='off']:not([type])") || document.querySelector("input[type='text'][name][value],input[name][value]:not([type])");
  1192. }
  1193. debug("插入的位置为 %o", iTarget);
  1194. debug("匹配的输入框为 %o", iInput);
  1195.  
  1196. if (!iTarget || !iInput) {
  1197. debug("不存在插入的位置或匹配的输入框", iTarget, iInput);
  1198. return;
  1199. }
  1200.  
  1201. addGlobalStyle();
  1202.  
  1203. // 判断是否存在
  1204. var container = document.getElementById("sej-container");
  1205.  
  1206. if (!container) {} else if (container) {
  1207. container.parentNode.removeChild(container);
  1208. }
  1209. addContainer(iTarget, iInput);
  1210. container = document.getElementById("sej-container");
  1211. if(container)container.style.left = "calc(50% - " + getComputedStyle(container).width + " / 2)";
  1212. }
  1213.  
  1214. function remove() {
  1215. var elems = document.querySelectorAll("#sej-container");
  1216. if (!elems) return;
  1217.  
  1218. [].forEach.call(elems, function(elem) {
  1219. elem.parentNode.removeChild(elem);
  1220. });
  1221. elems = document.querySelectorAll("#sej-button");
  1222. [].forEach.call(elems, function(elem) {
  1223. elem.parentNode.removeChild(elem);
  1224. });
  1225. }
  1226.  
  1227. // iframe 禁止加载
  1228. if (window.self != window.top) return;
  1229. loadPrefs();
  1230. var matchedRule;
  1231.  
  1232. rules.some(function(rule) {
  1233. if (toRE(rule.url).test(location.href)) {
  1234. matchedRule = rule;
  1235. if (typeof rule.etc == "function") {
  1236. try {
  1237. rule.etc();
  1238. } catch (ex) {
  1239. console.error("执行 etc 错误", ex);
  1240. }
  1241. }
  1242. return true;
  1243. }
  1244. });
  1245.  
  1246. var flag = 0;
  1247. debug("匹配的规则为", matchedRule);
  1248. debug("脚本执行于:"+document.readyState);
  1249. debug("onreadystatechange function:"+document.onreadystatechange);
  1250. if (!matchedRule) return;
  1251. GM_registerMenuCommand("设置",openPrefs);
  1252. document.onreadystatechange = function() {
  1253. flag = 1;
  1254. if (document.readyState == "interactive") {
  1255. debug("onreadystatechange: " + document.readyState);
  1256. run();
  1257. } else if (document.readyState == "complete") {
  1258. debug("onreadystatechange: " + document.readyState);
  1259. run();
  1260. /*if (window.navigator.userAgent.indexOf("Chrome") != -1) {
  1261. setTimeout(run(), 1000);
  1262. }*/
  1263. }
  1264. };
  1265. window.onload = function() {//用于DuckDuckGo,影响到了onreadystatechange
  1266. debug("onload");
  1267. if (flag == 0)run();
  1268. flag = 1;
  1269. };
  1270. if (matchedRule.mutationTitle) {
  1271. debug("添加标题节点监视器: title");
  1272. var watch = document.querySelector("title");
  1273. var observer = new window.MutationObserver(function(mutations) {
  1274. debug("标题发生了变化", document.title);
  1275. run();
  1276. });
  1277. observer.observe(watch, {
  1278. childList: true,
  1279. subtree: true,
  1280. characterData: true
  1281. });
  1282. }
  1283. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址