searchEngineJumpCE-modify by ted423

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

目前为 2015-12-02 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name searchEngineJumpCE-modify by ted423
  3. // @author NLF && ywzhaiqi
  4. // @contributor ted423
  5. // @description 方便的在各个引擎之间跳转。可自定义搜索列表的 NLF 修改版。
  6. // @version 7.1512.02.0
  7. // @namespace https://gf.qytechs.cn/users/85
  8. // @grant none
  9. // @run-at document-end
  10. // ==/UserScript==
  11. (function(){
  12. 'use strict';
  13. var prefs = {
  14. openInNewTab: false, // 是否在新页面打开.
  15. hidePrefsBtn: false, // 隐藏设置按钮
  16. hideEnglineLabel: 0, // 是否隐藏前几个搜索的文字部分。0:不隐藏,1:根据高度自行判断,2:隐藏
  17. engineListDataType: 'ted423', // 搜索列表默认类型
  18. iconType: '', // 获取 icon 的在线服务的地址类型
  19. //position: '', // 全局搜索条插入的位置:default, left, top
  20. debug: true,
  21. };
  22.  
  23. var engineListData = {
  24. custom: '',
  25. ted423: '网页\n 百度, https://www.baidu.com/s?wd=%s&ie=utf-8\n 360, http://www.haosou.com/s?ie=utf-8&q=%s\n bing, https://cn.bing.com/search?q=%s&pc=OPER\n 搜狗, http://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, http://search.yahoo.co.jp/search?p=%s&aq=-1&oq=&ei=UTF-8&fr=top_ga1_sa&x=wrt\n Google--百度\n Google.hk, https://www.google.com.hk/search?q=%s&ie=utf-8&safe=off, https://i.imgur.com/xK23DKf.png\n Google.co.jp,https://www.google.co.jp/search?q=%s&ie=utf-8&safe=off, https://i.imgur.com/xK23DKf.png\n资料-Scholar\n 百科, http://baike.baidu.com/searchword/?word=%s&pic=1&sug=1&ie=utf-8\n Scholar, http://scholar.google.com/scholar?hl=zh-CN&q=%s&btnG=&lr=, https://i.imgur.com/hJVSUU5.png\n 学术, http://xueshu.baidu.com/s?wd=%s\n 知乎, http://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=%E6%90%9C%E7%B4%A2%E5%9B%BE%E4%B9%A6&tbm=bks&tbo=1&hl=zh-CN&gws_rd=ssl, https://i.imgur.com/xK23DKf.png\n WIKI--百科\n ZWIKI, http://zh.wikipedia.org/w/index.php?search=%s&button=&title=Special%3ASearch, https://zh.wikipedia.org/static/favicon/wikipedia.ico\n EWIKI, https://en.wikipedia.org/w/index.php?search=%s&button=&title=Special%3ASearch, https://zh.wikipedia.org/static/favicon/wikipedia.ico\n JWIKI, http://ja.wikipedia.org/w/index.php?search=%s&button=&title=Special%3ASearch, https://zh.wikipedia.org/static/favicon/wikipedia.ico\n 开发--百科\n stackoverflow, http://stackoverflow.com/search?q=%s, http://cdn.sstatic.net/stackoverflow/img/favicon.ico\n MDN, https://developer.mozilla.org/en-US/search?q=%s,https://developer.cdn.mozilla.net/media/img/favicon32.png\n github, https://github.com/search?q=%s\n krugle, http://opensearch.krugle.org/document/search/#query=%s,http://opensearch.krugle.org/media/images/favicon.ico\n npm, https://www.npmjs.org/search?q=%s, http://i.imgur.com/Ec0WrY8.png\n地图\n 百度, http://map.baidu.com/?newmap=1&ie=utf-8&s=s%26wd%3D%s\n Google, https://www.google.com/maps/search/%s/\n 搜狗, http://map.sogou.com/#lq=%s\n Bing, https://www.bing.com/ditu/?q=%s\n音乐\n 天天动听, http://www.dongting.com/#a=searchlist&q=%s\n Music, http://music.baidu.com/search?key=%s&ie=utf-8&oe=utf-8\n 搜狗, http://mp3.sogou.com/music.so?query=%s\n 一听, http://so.1ting.com/all.do?q=%s\n 虾米, http://www.xiami.com/search?key=%s\n piapro, http://piapro.jp/search/?view=audio&keyword=%s\n Lyric, http://music.baidu.com/search/lrc?key=%s\n图片-Flickr\n 百度, http://image.baidu.com/search/index?tn=baiduimage&word=%s\n Google, https://www.google.com.hk/search?tbm=isch&q=%s, https://i.imgur.com/xK23DKf.png\n 花瓣, http://huaban.com/search/?q=%s\n Picsearch, http://cn.picsearch.com/index.cgi?q=%s\n Flickr, http://www.flickr.com/search/?w=all&q=%s\n Pixiv, http://www.pixiv.net/search.php?s_mode=s_tag&word=%s\n dA, http://www.deviantart.com/?q=%s, UTF16\n , http://img.jpg4.info/index.php?feed=%s, https://i.imgur.com/qkOEi8O.png\n下载-nyaa\n dmhy, http://share.dmhy.org/topics/list?keyword=%s\n kickass, https://kat.cr/usearch/%s/, http://i.imgur.com/uz2GaPN.png\n BTSOW, http://www.bt2mag.com/search/%s, http://www.bt2mag.com/app/bts/View/img/btsow.com.favicon.ico\n BTDigg, https://btdigg.org/search?q=%s\n ed2000, https://www.baidu.com/s?wd=%s+site:ed2000.com&ie=utf-8, http://www.biaoqing.com/2000/favicon.ico\n 字幕--下载\n subom, http://www.subom.net/search/%s\n , http://subhd.com/search/%s, https://i.imgur.com/kC8RATC.png\n 射手网(伪), http://sub.makedie.me/sub/?searchword=%s\n nyaa--dmhy\n nyaa.se, http://www.nyaa.se/?page=search&term=%s, https://i292.photobucket.com/albums/mm30/ted423/favicon_zpsdxwbxo6t.png\n nyaa.eu, http://www.nyaa.eu/?page=search&term=%s, https://i292.photobucket.com/albums/mm30/ted423/favicon_zpsdxwbxo6t.png\n sukebei.nyaa.se, http://sukebei.nyaa.se/?page=search&cats=0_0&filter=0&term=%s, https://i292.photobucket.com/albums/mm30/ted423/favicon_zpsdxwbxo6t.png\n sukebei.nyaa.eu, http://sukebei.nyaa.eu/?page=search&cats=0_0&filter=0&term=%s, https://i292.photobucket.com/albums/mm30/ted423/favicon_zpsdxwbxo6t.png\n网购\n 一淘, http://s.etao.com/search?q=%s\n 京东, http://search.jd.com/Search?keyword=%s&enc=utf-8\n 淘宝, http://s.taobao.com/search?q=%s, http://www.taobao.com/favicon.ico\n 亚马逊, http://www.amazon.cn/s/ref=nb_ss?keywords=%s\netc\n AMO, https://addons.mozilla.org/zh-CN/firefox/search/?q=%s, https://addons.cdn.mozilla.net/favicon.ico\n 汉典, http://www.zdic.net/sousuo/?q=%s&tp=tp3\n',
  26. };
  27.  
  28. var MAIN_CSS = '#sej-container {\n box-shadow:0px 0px 3px #aaaaaa;\n opacity: 0.7;\n display:table;\n font-family: Comic Sans MS,"Microsoft YaHei",微软雅黑;\n position: relative;\n padding: 1px 0 1px 10px;\n line-height: 1.5;\n font-size: 13px;\n}\n\n\n#sej-expanded-category {\n font-weight: bold;\n}\n#sej-expanded-category::after {\n content:":";\n}\n\n\n.sej-engine {\n line-height: 2;\n display: inline-block;\n margin: 0;\n border: none;\n padding: 0 4px;\n text-decoration: none;\n color: #120886 !important;\n transition: background-color 0.15s ease-in-out;\n}\na.sej-engine.only-icon {\n margin-left: 3px;\n margin-right: 3px;\n}\na.sej-engine.only-icon > span {\n display: none;\n}\na.sej-engine:link, a.sej-engine:visited{\n text-decoration: none;\n}\na.sej-engine:visited, a.sej-engine:visited *, a.sej-engine:active, a.sej-engine:active *{\n color: #120886 !important;\n}\n.sej-drop-list-trigger {\n\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 vertical-align: middle;\n transition: -webkit-transform 0.3s ease-in-out;\n transition: transform 0.3s ease-in-out;\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-drop-list > .sej-engine {\n display: block;\n padding-top: 4px;\n padding-bottom: 4px;\n}\n.sej-drop-list > .sej-engine:hover {\n background-color: #DEEDFF;\n}\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: text-bottom;\n}\n\n\n.sej-drop-list {\n position: absolute;\n display: none;\n opacity: 0.3;\n top: -10000px;\n left: 0;\n min-width: 120px;\n border: 1px solid #FAFAFA;\n padding: 5px 0;\n text-align: center;\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 transition: opacity 0.2s ease-in-out,\n top 0.2s ease-in-out;\n}';
  29.  
  30.  
  31. var categoryMap = {// rules 和 engineList 的对应
  32. 'web': '网页',
  33. 'map': '地图',
  34. 'video': '视频',
  35. 'music': '音乐',
  36. 'image': '图片',
  37. 'knowledge': '资料',
  38. 'sociality': '社交',
  39. 'shopping': '网购',
  40. 'download': '下载',
  41. };
  42.  
  43. function isTheSameCategory(c1, c2) {
  44. return (categoryMap[c1] || c1) == (categoryMap[c2] || c2);
  45. }
  46.  
  47.  
  48. var rules = [// 根据规则把搜索引擎列表插入到指定网站
  49. // 网页
  50. // /////////////第一个可以当模板看
  51. {
  52. name: "google网页搜索",// 你要加载的网站的名字(方便自己查找)
  53. enabled: true,// 是否启用
  54. url: /^https?:\/\/(www|encrypted)\.google\.(?!co\.jp)[^\/]{2,9}\/(webhp|search|#|$|\?)(?!.*tbm=)/,// 在哪个网站上加载,正则.
  55. mutationTitle: true, // 是否要监视标题的变化
  56. engineList: 'web',// 加载哪个类型的列表:
  57. style: '\
  58. border-bottom: 1px solid #E5E5E5;\
  59. border-top: 1px solid #E5E5E5;\
  60. width:100%;\
  61. padding-left: 15px;\
  62. ',// 给引擎列表的样式
  63. // 插入文档,相关
  64. // target 将引擎跳转工具栏插入到文档的某个元素
  65. // (请使用css匹配(请加上 'css;' 的前缀),比如: 'css;#subform_ctrl' );
  66. // keyword 使用 css选中一个form input元素 或者 该项是一个函数,使用返回值
  67. // where 四种:
  68. // 'beforeBegin'(插入到给定元素的前面) ;
  69. // 'afterBegin'(作为给定元素的第一个子元素) ;
  70. // 'beforeEnd' (作为给定元素的最后一个子元素) ;
  71. // 'afterEnd'(插入到给定元素的后面);.
  72. insertIntoDoc: {
  73. keyword: 'css;input[name="q"]',
  74. target: 'css;#top_nav',
  75. where: 'beforeBegin',
  76. },
  77. stylish: '',// 自定义样式
  78. },
  79. {
  80. name: "google.co.jp",
  81. enabled: true,
  82. url: /^https?:\/\/(www|encrypted)\.google\.co\.jp\/(webhp|search|#|$|\?)(?:.(?!&tbm=))*$/,
  83. mutationTitle: true,
  84. engineList: 'web',
  85. style: '\
  86. border-bottom: 1px solid #E5E5E5;\
  87. border-top: 1px solid #E5E5E5;\
  88. width:100%;\
  89. padding-left: 15px;\
  90. ',
  91.  
  92.  
  93. insertIntoDoc: {
  94. keyword: 'css;input[name="q"]',
  95. target: 'css;#top_nav',
  96. where: 'beforeBegin',
  97. },
  98. },
  99. {
  100. name: "baidu 网页搜索",
  101. url: /^https?:\/\/www\.baidu\.com\/(?:s(?!.*tn=baidulocal)|baidu(?!.*tn=baidulocal)|)/,
  102. mutationTitle: true,
  103. enabled: true,
  104. engineList: 'web',
  105. style: '\
  106. border-top:1px solid #D9E1F7;\
  107. border-bottom:1px solid #D9E1F7;\
  108. margin-left: 122px;\
  109. ',
  110. insertIntoDoc: {
  111. keyword: 'css;#kw',
  112. target: 'css;#container',
  113. where: 'beforeBegin',
  114. },
  115. },
  116. {
  117. name: "baidu 简洁搜索",//百度简洁搜索:https://www.baidu.com/s?wd=firefox&ie=utf-8&tn=baidulocal
  118. url: /^https?:\/\/www\.baidu\.com\/s\?.*tn=baidulocal/,
  119. enabled: true,
  120. engineList: 'web',
  121. style: '\
  122. border-top:1px solid #D9E1F7;\
  123. border-bottom:1px solid #D9E1F7;\
  124. margin-left: 122px;\
  125. ',
  126. insertIntoDoc: {
  127. keyword: 'css;input[name="wd"]',
  128. target: 'css;table[bgcolor="#e6e6e6"]',
  129. where: 'beforeBegin',
  130. },
  131. },
  132. {
  133. name: "必应网页搜索",
  134. url: /^https?:\/\/[^.]*\.bing\.com\/search/,
  135. enabled: true,
  136. engineList: 'web',
  137. style: '\
  138. border-collapse:separate;\
  139. border-top: 1px solid #E6E6E6;\
  140. border-bottom: 1px solid #E6E6E6;\
  141. margin-left: 10px;\
  142. ',
  143. insertIntoDoc: {
  144. keyword: 'css;#sb_form_q',
  145. target: 'css;#b_header',
  146. where: 'beforeEnd',
  147. },
  148. stylish: '#b_content{ padding: 10px 0px 20px 100px !important; } .b_underSearchbox{margin:5px 20px 0px;}'
  149. },
  150. {
  151. name: "360搜索",
  152. url: /^https?:\/\/www\.haosou\.com\/s\?/,
  153. engineList: 'web',
  154. enabled: true,
  155. style: '\
  156. border-bottom: 1px solid #E0E0E0;\
  157. border-top: 1px solid #E0E0E0;\
  158. margin-left: 20px;\
  159. ',
  160. insertIntoDoc: {
  161. keyword: 'css;#keyword',
  162. target: 'css;#head',
  163. where: 'afterEnd',
  164. },
  165. stylish: '#header .inner{height: 116px !important;}'
  166. },
  167. {
  168. name: "搜狗网页搜索",
  169. url: /^https?:\/\/www\.sogou\.com\/(?:web|s)/,
  170. enabled: true,
  171. engineList: 'web',
  172. style: "\
  173. margin-bottom: 10px;\
  174. margin-left: 35px;\
  175. ",
  176. insertIntoDoc: {
  177. keyword: 'css;#upquery',
  178. target: 'css;#wrapper',
  179. where: 'beforeBegin',
  180. },
  181. stylish: '.header{ margin-bottom: 5px; }'
  182. },
  183. {
  184. name: "雅虎网页搜索",
  185. url: /^https?:\/\/search\.yahoo\.com\/search/,
  186. engineList: '网页',
  187. enabled: true,
  188. style: "\
  189. text-align:left;\
  190. border-top:1px solid #D4E9F7;\
  191. border-bottom:1px solid #D4E9F7;\
  192. ",
  193. insertIntoDoc: {
  194. keyword: 'css;#yschsp',
  195. target: 'css;#hd',
  196. where: 'afterEnd'
  197. },
  198. stylish: '#doc #sticky-hd ~ #bd {margin-top: 110px;}'
  199. },
  200. {
  201. name: "tw.yahoo",
  202. url: /^https?:\/\/tw\.search\.yahoo\.com\/search/,
  203. engineList: '网页',
  204. enabled: true,
  205. style: "\
  206. margin-left:15px;\
  207. margin-top:5px;\
  208. border-top:1px solid #D4E9F7;\
  209. border-bottom:1px solid #D4E9F7;\
  210. ",
  211. insertIntoDoc: {
  212. keyword: 'css;#yschsp',
  213. target: 'css;#sticky-hd',
  214. where: 'beforeEnd'
  215. },
  216. stylish: '#bd {margin-top: 105px!important;}'
  217. },
  218. {
  219. name: "yahoo.co.jp",
  220. url: /^https?:\/\/search\.yahoo\.co\.jp\/search/,
  221. engineList: '网页',
  222. enabled: true,
  223. style: "\
  224. margin:0px auto;\
  225. border:1px solid #D4E9F7;\
  226. ",
  227. insertIntoDoc: {
  228. keyword: 'css;#yschsp',
  229. target: 'css;#ygma',
  230. where: 'afterEnd'
  231. },
  232. },
  233. {
  234. name: "duckduckgo",
  235. url: /^https?:\/\/duckduckgo\.com\/\?/,
  236. engineList: '网页',
  237. enabled: true,
  238. style: "\
  239. margin-left:15px;\
  240. border:1px solid #D4E9F7;\
  241. ",
  242. insertIntoDoc: {
  243. keyword: 'css;#search_form_input',
  244. target: 'css;#zero_click_wrapper',
  245. where: 'afterEnd'
  246. },
  247. },
  248. // 知识
  249. {
  250. name: "谷歌学术",
  251. enabled: true,
  252. url: /^https?:\/\/scholar\.google(?:\.\D{1,3}){1,2}\/scholar\?/,
  253. engineList: "资料",
  254. style: '\
  255. border-bottom:1px solid #E5E5E5;\
  256. border-top:1px solid #E5E5E5;\
  257. z-index:999;\
  258. position:relative;\
  259. ',
  260. insertIntoDoc: {
  261. target: 'css;#gs_ab',
  262. keyword: 'css;input[name="q"]',
  263. where: 'beforeBegin'
  264. }
  265. },
  266. {
  267. name: "百度学术",
  268. url: /^https?:\/\/xueshu\.baidu\.com\/s\?/,
  269. enabled: true,
  270. engineList: '资料',
  271. style: '\
  272. border-bottom:1px solid #D9E1F7;\
  273. ',
  274. insertIntoDoc: {
  275. keyword: 'css;#kw',
  276. target: 'css;#head',
  277. where: 'afterEnd',
  278. },
  279. stylish: '#container{padding-top: 130px !important;}'
  280. },
  281. {
  282. name: "百度百科",
  283. url: /^https?:\/\/baike\.baidu\.com\/(search|view|subview)/,
  284. engineList: "资料",
  285. enabled: true,
  286. style: "\
  287. margin:0 auto;\
  288. z-index: 999999;\
  289. ",
  290. insertIntoDoc: {
  291. keyword: 'css;input#query',
  292. target: 'css;.header-wrapper',
  293. where: 'afterEnd',
  294. },
  295. },
  296. {
  297. name: "萌娘百科",
  298. url: /^https?:\/\/zh\.moegirl\.org\/./,
  299. engineList: "资料",
  300. enabled: true,
  301. style: "\
  302. z-index: 999999;\
  303. ",
  304. insertIntoDoc: {
  305. keyword: function () {
  306. if(document.getElementById('searchText'))return document.getElementById('searchText').value;
  307. else return document.getElementById('firstHeading').textContent;
  308. },
  309. target: 'css;#content',
  310. where: 'afterBegin',
  311. },
  312. },
  313. {
  314. name: "google book",
  315. enabled: true,
  316. url: /^https?:\/\/www\.google\.co.{1,3}\/search\?.*(&btnG=%E6)|(tbm=bks)/,
  317. mutationTitle: true,
  318. engineList: '资料',
  319. style: '\
  320. border-bottom: 1px solid #E5E5E5;\
  321. border-top: 1px solid #E5E5E5;\
  322. width:100%;\
  323. padding-left: 15px;\
  324. ',
  325.  
  326.  
  327. insertIntoDoc: {
  328. keyword: 'css;input[name="q"]',
  329. target: 'css;#top_nav',
  330. where: 'beforeBegin',
  331. },
  332. },
  333. {
  334. name: "互知识",
  335. url: /^https?:\/\/[a-z]{2,3}\.baike\.com\/[a-z]/,
  336. enabled: true,
  337. engineList: "资料",
  338. style: '\
  339. position:fixed;\
  340. top:80px;\
  341. right:2%;\
  342. width:90px;\
  343. z-index:99;\
  344. margin:0 auto;\
  345. ',
  346. insertIntoDoc: {
  347. keyword: function() {
  348. var input;
  349. if (document.getElementsByClassName('ac_input')[0] != undefined) {
  350. if (document.getElementsByClassName('ac_input')[0].value != "")
  351. input = document.getElementsByClassName('ac_input')[0].value;
  352. else if (document.getElementsByClassName('blue')[0].innerHTML != "") input = document.getElementsByClassName('blue')[0].innerHTML;
  353. else input = document.evaluate("//h1", document, null, 9, null).singleNodeValue.innerHTML;
  354. } else if (document.getElementsByClassName('blue')[0].innerHTML != "") input = document.getElementsByClassName('blue')[0].innerHTML;
  355. else input = document.evaluate("//h1", document, null, 9, null).singleNodeValue.innerHTML;
  356. return input;
  357. },
  358. target: 'css;body',
  359. where: 'afterbegin'
  360. }
  361. },
  362. {
  363. name: "wiki",
  364. url: /^https?:\/\/..\.wikipedia\.org\/w\/index\.php(?!.*\?search=)/,
  365. enabled: true,
  366. engineList: "资料",
  367. style: '\
  368. border-top:1px solid #D9E1F7;\
  369. border-bottom:1px solid #D9E1F7;\
  370. margin-top:5px;\
  371. ',
  372. insertIntoDoc: {
  373. keyword: 'css;#searchInput',
  374. target: 'css;#siteNotice',
  375. where: 'beforeBegin'
  376. }
  377. },
  378. {
  379. name: "wiki[ZH]",
  380. url: /^https?:\/\/zh\.wikipedia\.org\/(?:zh|wiki\/|w\/index.php\?search=)/,
  381. enabled: true,
  382. engineList: "资料",
  383. style: '\
  384. border-top:1px solid #D9E1F7;\
  385. border-bottom:1px solid #D9E1F7;\
  386. margin-top:5px;\
  387. ',
  388. insertIntoDoc: {
  389. keyword: function () {
  390. if(document.getElementById('searchText'))
  391. return document.getElementById('searchText').value;
  392. else return document.getElementById('firstHeading').childNodes[0].textContent;
  393. },
  394. target: 'css;#siteNotice',
  395. where: 'beforeBegin'
  396. }
  397. },
  398. {
  399. name: "wiki[EN]",
  400. url: /^https?:\/\/en\.wikipedia\.org\/(wiki\/|w\/index\.php\?search=)/,
  401. enabled: true,
  402. engineList: "资料",
  403. style: '\
  404. border-top:1px solid #D9E1F7;\
  405. border-bottom:1px solid #D9E1F7;\
  406. margin-top:5px;\
  407. ',
  408. insertIntoDoc: {
  409. keyword: function () {
  410. if(document.getElementById('searchText'))
  411. return document.getElementById('searchText').value;
  412. else return document.getElementById('firstHeading').childNodes[0].textContent;
  413. },
  414. target: 'css;#siteNotice',
  415. where: 'beforeBegin'
  416. }
  417. },
  418. {
  419. name: "wiki[JP]",
  420. url: /^https?:\/\/ja\.wikipedia\.org\/(wiki\/|w\/index\.php\?search=)/,
  421. enabled: true,
  422. engineList: "资料",
  423. style: '\
  424. border-top:1px solid #D9E1F7;\
  425. border-bottom:1px solid #D9E1F7;\
  426. margin-top:5px;\
  427. ',
  428. insertIntoDoc: {
  429. keyword: function () {
  430. if(document.getElementById('searchText'))
  431. return document.getElementById('searchText').value;
  432. else return document.getElementById('firstHeading').childNodes[0].textContent;
  433. },
  434. target: 'css;#siteNotice',
  435. where: 'beforeBegin'
  436. }
  437. },
  438. {
  439. name: "百度知道(search)",
  440. url: /^https?:\/\/zhidao\.baidu\.com\/search/,
  441. enabled: true,
  442. engineList: "资料",
  443. style: '\
  444. margin-bottom: 8px;\
  445. ',
  446. insertIntoDoc: {
  447. keyword: 'css;input#kw',
  448. target: 'css;#body',
  449. where: 'beforeBegin'
  450. },
  451. },
  452. {
  453. name: "百度知道(question)",
  454. url: /^https?:\/\/zhidao\.baidu\.com\/question/,
  455. enabled: true,
  456. engineList: "资料",
  457. style: '\
  458. width: 980px;\
  459. margin: 0 auto;\
  460. white-space: nowrap;\
  461. ',
  462. insertIntoDoc: {
  463. keyword: function() {
  464. return document.querySelector('#kw').value;
  465. },
  466. target: 'css;#body',
  467. where: 'beforeBegin'
  468. },
  469. endFix: function() { // 插入搜索条后修正绿色背景错位的问题
  470. var container = document.getElementById('sej-container');
  471. if (container && document.body.classList.contains('has-menu')) {
  472. document.body.style.backgroundPosition = '0px ' + ( 95 + container.clientHeight ) + 'px';
  473. }
  474. },
  475. },
  476. {
  477. name: "知乎",
  478. url: /^https?:\/\/www\.zhihu\.com\/search\?/,
  479. enabled: true,
  480. engineList: "资料",
  481. style: '\
  482. border-bottom:1px solid #D9E1F7;\
  483. margin: 0 auto;\
  484. ',
  485. insertIntoDoc: {
  486. keyword: 'css;input#q',
  487. target: 'css;.zu-top',
  488. where: 'afterEnd'
  489. },
  490. },
  491. {
  492. name: "百度文库",
  493. url: /^https?:\/\/wenku\.baidu\.com\/search\?/,
  494. enabled: true,
  495. engineList: "资料",
  496. style: '\
  497. border-top:1px solid #D9E1F7;\
  498. border-bottom:1px solid #D9E1F7;\
  499. ',
  500. insertIntoDoc: {
  501. keyword: 'css;input#kw',
  502. target: 'css;#hd',
  503. where: 'afterEnd'
  504. }
  505. },
  506. {
  507. name: "豆丁",
  508. url: /^https?:\/\/www\.docin\.com\/search\.do/,
  509. enabled: true,
  510. engineList: "资料",
  511. style: '\
  512. margin:0 auto;\
  513. padding-top:65px;\
  514. border-top:1px solid #00000;\
  515. border-bottom:1px solid #D9E1F7;\
  516. ',
  517. insertIntoDoc: {
  518. keyword: 'css;input#topsearch',
  519. target: 'css;.nav',
  520. where: 'beforeBegin'
  521. }
  522. },
  523. // 地图
  524. {
  525. name: "百度地图",
  526. url: /^https?:\/\/map\.baidu\.com\/\?newmap/,
  527. enabled: true,
  528. engineList: "map",
  529. style: '\
  530. margin-left:20px;\
  531. border-top:1px solid #00000;\
  532. border-bottom:1px solid #D9E1F7;\
  533. ',
  534. insertIntoDoc: {
  535. keyword: 'css;input#PoiSearch',
  536. target: 'css;#searchWrapper',
  537. where: 'beforeEnd'
  538. }
  539. },
  540. {
  541. name: "google地图",
  542. url: /^https?:\/\/www\.google\.co.{1,4}\/maps/,
  543. enabled: true,
  544. engineList: "map",
  545. style: '\
  546. margin-top: 3px;\
  547. ',
  548. insertIntoDoc: {
  549. keyword: 'css;input#searchboxinput',
  550. target: 'css;#omnibox',
  551. where: 'beforeEnd'
  552. },
  553. stylish:'.widget-pane-section-omnibox-spacer{height:90px !important;} .sej-drop-list-trigger{display:none;}',
  554. },
  555. {
  556. name: "搜狗地图",
  557. url: /^https?:\/\/map\.sogou\.com\/#/,
  558. enabled: true,
  559. engineList: "map",
  560. style: '\
  561. padding-left:15px;\
  562. display:block;\
  563. border-top:1px solid #00000;\
  564. border-bottom:1px solid #D9E1F7;\
  565. word-break:keep-all;\
  566. white-space:nowrap;\
  567. ',
  568. insertIntoDoc: {
  569. keyword: 'css;input#query',
  570. target: 'css;#search_form',
  571. where: 'afterEnd'
  572. },
  573. stylish: '.sej-drop-list-trigger {display:none;}'
  574. },
  575. {
  576. name: "Bing地图",
  577. url: /^https?:\/\/[^.]*\.bing\.com\/ditu\//,
  578. enabled: true,
  579. engineList: "map",
  580. style: '\
  581. display: inline-block;\
  582. margin-left:15px;\
  583. border-top:1px solid #00000;\
  584. border-bottom:1px solid #D9E1F7;\
  585. word-break:keep-all;\
  586. white-space:nowrap;\
  587. ',
  588. insertIntoDoc: {
  589. keyword: 'css;input#sb_form_q',
  590. target: 'css;#sw_content',
  591. where: 'beforeBegin'
  592. }
  593. },
  594. // 音乐
  595. {
  596. name: "天天动听",
  597. url: /^https?:\/\/www\.dongting\.com\/#/,
  598. enabled: true,
  599. engineList: "music",
  600. style: "\
  601. margin-left:23%;\
  602. background-color:#E2E2E2;\
  603. position: fixed;\
  604. right:0;\
  605. ",
  606. insertIntoDoc: {
  607. keyword: 'css;.searchBox',
  608. target: 'css;.head',
  609. where: 'beforeEnd'
  610. }
  611. },
  612. {
  613. name: "百度音乐",
  614. url: /^https?:\/\/music\.baidu\.com\/search/,
  615. enabled: true,
  616. engineList: "music",
  617. style: "\
  618. margin:0 auto;\
  619. ",
  620. insertIntoDoc: {
  621. keyword: 'css;#ww',
  622. target: 'css;.nav-wrapper',
  623. where: 'beforeBegin'
  624. }
  625. },
  626. {
  627. name: "qq音乐",
  628. url: /^https?:\/\/cgi\.music\.soso\.com/,
  629. enabled: true,
  630. engineList: "music",
  631. style: "\
  632. margin:2px auto;\
  633. ",
  634. insertIntoDoc: {
  635. keyword: 'css;#search_input',
  636. target: 'css;#search_result',
  637. where: 'beforeBegin'
  638. }
  639. },
  640. {
  641. name: "搜狗音乐",
  642. url: /^https?:\/\/mp3\.sogou\.com\/music\.so/,
  643. enabled: true,
  644. engineList: "music",
  645. style: "\
  646. margin:0 auto;\
  647. ",
  648. insertIntoDoc: {
  649. keyword: 'css;#queryinput',
  650. target: 'css;#header_sogou',
  651. where: 'afterEnd'
  652. }
  653. },
  654. {
  655. name: "音悦台",
  656. url: /^https?:\/\/so\.yinyuetai\.com\/mv\?/,
  657. enabled: true,
  658. engineList: "music",
  659. style: "\
  660. margin:0 auto;\
  661. ",
  662. insertIntoDoc: {
  663. keyword: 'css;input[name="keyword"]',
  664. target: 'css;.search_title',
  665. where: 'beforeBegin'
  666. },
  667. },
  668. {
  669. name: "一听音乐",
  670. url: /^https?:\/\/so\.1ting\.com\//,
  671. enabled: true,
  672. engineList: "music",
  673. style: "\
  674. margin:0 auto;\
  675. width: 960px;\
  676. ",
  677. insertIntoDoc: {
  678. keyword: 'css;#keyword',
  679. target: 'css;.nav',
  680. where: 'beforeBegin'
  681. }
  682. },
  683. {
  684. name: "songtaste",
  685. url: /^https?:\/\/www\.songtaste\.com\/search/,
  686. enabled: true,
  687. engineList: "music",
  688. style: "\
  689. margin:0 auto;\
  690. word-break:keep-all;\
  691. white-space:nowrap;\
  692. background-color:#E6E6E6;\
  693. ",
  694. insertIntoDoc: {
  695. keyword: 'css;#sb',
  696. target: 'css;head',
  697. where: 'beforeBegin'
  698. }
  699. },
  700. {
  701. name: "xiami",
  702. url: /^https?:\/\/www\.xiami\.com\/search/,
  703. enabled: true,
  704. engineList: "music",
  705. style: "\
  706. word-break:keep-all;\
  707. margin-right: 205px;\
  708. ",
  709. insertIntoDoc: {
  710. keyword: 'css;#search_text',
  711. target: 'css;.more_cols_left_inner',
  712. where: 'beforeBegin'
  713. }
  714. },
  715.  
  716. // 图片
  717. {
  718. name: "谷歌图片",
  719. url: /^https?:\/\/\w{2,10}\.google(?:\.\D{1,3}){1,2}\/search\?(.*tbs=sbi)|(.*tbm=isch)/,
  720. enabled: true,
  721. engineList: "image",
  722. style: '\
  723. border-top:1px solid #ccc;\
  724. border-bottom:1px solid #ccc;\
  725. ',
  726. insertIntoDoc: {
  727. keyword: 'css;input[name=q]',
  728. target: 'css;#top_nav',
  729. where: 'beforeBegin'
  730. }
  731. },
  732. {
  733. name: "百度图片",
  734. url: /^https?:\/\/image\.baidu\.c(om|n)\/search/,
  735. enabled: true,
  736. engineList: "image",
  737. style: '\
  738. margin-left:40px;\
  739. ',
  740. insertIntoDoc: {
  741. keyword: 'css;input#kw',
  742. target: 'css;#search',
  743. where: 'afterEnd'
  744. }
  745. },
  746. {
  747. name: "360图片",
  748. url: /^https?:\/\/\image\.so\.com\/i\?/,
  749. enabled: true,
  750. engineList: "image",
  751. style: '\
  752. word-break:keep-all;\
  753. white-space:nowrap;\
  754. position:relative;\
  755. z-index:50;\
  756. text-align:left;\
  757. ',
  758. insertIntoDoc: {
  759. keyword: 'css;input#search_kw',
  760. target: 'css;#searchBox',
  761. where: 'afterBegin'
  762. },
  763. etc: function() {
  764. document.getElementById("searchBox").style.height = '80px';
  765. }
  766. },
  767. {
  768. name: "bing图片",
  769. url: /^https?:\/\/.*\.bing\.com\/images\/search/,
  770. enabled: true,
  771. engineList: "image",
  772. style: '\
  773. top:-5px;\
  774. margin-left:5px;\
  775. border-collapse:separate;\
  776. ',
  777. insertIntoDoc: {
  778. keyword: 'css;#sb_form_q',
  779. target: 'css;#rfPane',
  780. where: 'beforeEnd'
  781. },
  782. etc: function() {
  783. document.getElementById("rf_hold").style.height = '120px';
  784. }
  785. },
  786. {
  787. name: "搜狗图片",
  788. url: /^https?:\/\/pic\.sogou\.com\/pic/,
  789. engineList: "image",
  790. enabled: true,
  791. style: "\
  792. top:-9px;\
  793. border-top:1px solid #BFBDEA;\
  794. border-bottom:1px solid #BFBDEA;\
  795. ",
  796. insertIntoDoc: {
  797. keyword: 'css;#form_querytext',
  798. target: 'css;.fix_area',
  799. where: 'beforeEnd'
  800. },
  801. etc: function() {
  802. document.getElementsByClassName("hd_fix")[0].style.height = '130px';
  803. document.getElementsByClassName("hd_fix")[0].nextElementSibling.style.height = '130px';
  804. }
  805. },
  806. {
  807. name: "有道图片",
  808. url: /^https?:\/\/image\.youdao\.com\/search/,
  809. engineList: "image",
  810. enabled: true,
  811. style: "\
  812. ",
  813. insertIntoDoc: {
  814. keyword: 'css;#query',
  815. target: 'css;#w',
  816. where: 'beforeBegin'
  817. }
  818. },
  819. {
  820. name: "花瓣",
  821. url: /^https?:\/\/huaban\.com\/search\/\?/,
  822. engineList: "image",
  823. enabled: true,
  824. style: "\
  825. width:100%;\
  826. background-color:#FFFFFF;\
  827. text-align:center;\
  828. ",
  829. insertIntoDoc: {
  830. keyword: 'css;#query',
  831. target: 'css;#header',
  832. where: 'beforeEnd'
  833. },
  834. stylish:'#page{padding-top: 75px;}',
  835. },
  836. {
  837. name: "flickr",
  838. url: /^https?:\/\/www\.flickr\.com\/search/,
  839. engineList: "image",
  840. enabled: true,
  841. style: "\
  842. position:fixed;\
  843. text-align:center;\
  844. top:65px;\
  845. left: 50%;\
  846. transform: translate(-50%, -50%);\
  847. width:auto;\
  848. z-index:1999;\
  849. background-color:#FFFFFF;\
  850. border-top:1px solid #EBF1FF;\
  851. border-bottom:1px solid #EBF1FF;\
  852. ",
  853. insertIntoDoc: {
  854. keyword: function() {
  855. var input = document.getElementById("gn-search-field");
  856. if (input) return input.value;
  857. else {
  858. var m = location.search.match(/q=([^&]+)/i);
  859. if (m) return true;
  860. }
  861. },
  862. target: 'css;body',
  863. where: 'beforeBegin'
  864. },
  865. endFix: function() {
  866. var container = document.getElementById('sej-container');
  867. if (container) {
  868. var height = (container.clientHeight + 3);
  869. document.getElementsByTagName("section")[0].style.setProperty("top", height + "px", "important");
  870. }
  871. }
  872. },
  873. {
  874. name: "picsearch",
  875. url: /^http:\/\/(..|...)\.picsearch\.com\/index\.cgi/,
  876. engineList: "image",
  877. enabled: true,
  878. style: "\
  879. margin-bottom:3px;\
  880. ",
  881. insertIntoDoc: {
  882. keyword: 'css;input[name=q]',
  883. target: 'css;#content',
  884. where: 'afterBegin'
  885. }
  886. },
  887. {
  888. name: "pixiv",
  889. url: /^http:\/\/www\.pixiv\.net\/search\.php/,
  890. engineList: "image",
  891. enabled: true,
  892. style: "\
  893. margin: 0 auto;\
  894. box-shadow:none;\
  895. ",
  896. insertIntoDoc: {
  897. keyword: 'css;input[name=word]',
  898. target: 'css;body',
  899. where: 'beforeBegin'
  900. }
  901. },
  902. {
  903. name: "deviantart",
  904. url: /^http:\/\/www\.deviantart\.com\/browse\/all\//,
  905. engineList: "image",
  906. enabled: true,
  907. style: "\
  908. margin-bottom:10px;\
  909. ",
  910. insertIntoDoc: {
  911. keyword: 'css;#searchInput',
  912. target: 'css;.browse-top-bar',
  913. where: 'afterEnd'
  914. }
  915. },
  916. {
  917. name: "jpg4",
  918. url: /^http:\/\/img\.jpg4\.info\//,
  919. engineList: "image",
  920. enabled: true,
  921. insertIntoDoc: {
  922. keyword: 'css;input[name="feed"]',
  923. target: 'css;div[align="center"]',
  924. where: 'beforeEnd'
  925. }
  926. },
  927.  
  928. // 下载
  929. {
  930. name: "我爱p2p",
  931. url: /^http:\/\/(?:oabt|www\.byhh)\.org\/\?topic_title=/,
  932. engineList: "下载",
  933. enabled: true,
  934. style: "\
  935. margin: 0 auto;\
  936. padding-left: 16px;\
  937. ",
  938. insertIntoDoc: {
  939. keyword: 'css;#username',
  940. target: 'css;#seamain',
  941. where: 'beforeEnd',
  942. },
  943. },
  944. {
  945. name: "dmhy",
  946. url: /^https?:\/\/share\.dmhy\.org\/topics\/list/,
  947. engineList: "download",
  948. enabled: true,
  949. style: "\
  950. margin:0 auto;\
  951. ",
  952. insertIntoDoc: {
  953. keyword: function(){var key=document.querySelector('#keyword').value;if(key)return key;else key=document.title.split(/「|」/)[1];return key;},
  954. target: 'css;.quick_search',
  955. where: 'afterEnd'
  956. }
  957. },
  958. {
  959. name: "kickass",
  960. url: /^https?:\/\/kat\.cr\/usearch\//,
  961. engineList: "download",
  962. enabled: true,
  963. style: "\
  964. ",
  965. insertIntoDoc: {
  966. keyword: 'css;#contentSearch',
  967. target: 'css;#menu',
  968. where: 'afterEnd'
  969. },
  970. },
  971. {
  972. name: "nyaa.se",
  973. url: /^https?:\/\/www\.nyaa\.se\/\?page=search/,
  974. engineList: "download",
  975. enabled: true,
  976. style: "\
  977. margin:0 auto;\
  978. top:44px;\
  979. position: fixed;\
  980. left: 50%;\
  981. transform: translate(-50%, 0px);\
  982. white-space: nowrap;\
  983. ",
  984. insertIntoDoc: {
  985. keyword: 'css;.inputsearchterm',
  986. target: 'css;#topbar',
  987. where: 'afterEnd'
  988. },
  989. stylish:'#main{padding-top:70px;}',
  990. },
  991. {
  992. name: "nyaa.eu",
  993. url: /^https?:\/\/www\.nyaa\.eu\/\?page=search/,
  994. engineList: "download",
  995. enabled: true,
  996. style: "\
  997. margin:0 auto;\
  998. top:44px;\
  999. position: fixed;\
  1000. left: 50%;\
  1001. transform: translate(-50%, 0px);\
  1002. white-space: nowrap;\
  1003. ",
  1004. insertIntoDoc: {
  1005. keyword: 'css;.inputsearchterm',
  1006. target: 'css;#topbar',
  1007. where: 'afterEnd'
  1008. },
  1009. stylish:'#main{padding-top:70px;}',
  1010. },
  1011. {
  1012. name: "sukebei.nyaa.se",
  1013. url: /^https?:\/\/sukebei\.nyaa\.se\/\?page=search/,
  1014. engineList: "download",
  1015. enabled: true,
  1016. style: "\
  1017. margin:0 auto;\
  1018. top:44px;\
  1019. position: fixed;\
  1020. left: 50%;\
  1021. transform: translate(-50%, 0px);\
  1022. white-space: nowrap;\
  1023. ",
  1024. insertIntoDoc: {
  1025. keyword: 'css;.inputsearchterm',
  1026. target: 'css;#topbar',
  1027. where: 'afterEnd'
  1028. },
  1029. stylish:'#main{padding-top:70px;}',
  1030. },
  1031. {
  1032. name: "sukebei.nyaa.eu",
  1033. url: /^https?:\/\/sukebei\.nyaa\.eu\/\?page=search/,
  1034. engineList: "download",
  1035. enabled: true,
  1036. style: "\
  1037. margin:0 auto;\
  1038. top:44px;\
  1039. position: fixed;\
  1040. left: 50%;\
  1041. transform: translate(-50%, 0px);\
  1042. white-space: nowrap;\
  1043. ",
  1044. insertIntoDoc: {
  1045. keyword: 'css;.inputsearchterm',
  1046. target: 'css;#topbar',
  1047. where: 'afterEnd'
  1048. },
  1049. stylish:'#main{padding-top:70px;}',
  1050. },
  1051. {
  1052. name: "ed2000",
  1053. url: /^https?:\/\/www\.ed2000\.com\/FileList\.asp/,
  1054. engineList: "download",
  1055. enabled: true,
  1056. style: "\
  1057. border: 1px solid #E5E5E5;\
  1058. ",
  1059. insertIntoDoc: {
  1060. keyword: 'css;input[name=SearchWord]',
  1061. target: 'css;.topsearch',
  1062. where: 'afterEnd'
  1063. },
  1064. },
  1065. {
  1066. name: "bt2mag",
  1067. url: /^https?:\/\/www\.bt2mag\.com\/search\//,
  1068. enabled: true,
  1069. engineList: "download",
  1070. style: '\
  1071. word-break:keep-all;\
  1072. white-space:nowrap;\
  1073. margin:10px auto;\
  1074. ',
  1075. insertIntoDoc: {
  1076. keyword: 'css;.form-inline > div:nth-child(1) > input:nth-child(1)',
  1077. target: 'css;.fullsearch-form.search',
  1078. where: 'afterEnd'
  1079. }
  1080. },
  1081. {
  1082. name: "torrentkitty",
  1083. url: /^https?:\/\/(www\.)?torrentkitty\.(com|org)\/search\//,
  1084. enabled: true,
  1085. engineList: "download",
  1086. style: '\
  1087. border-top:1px solid #FFFFFF;\
  1088. border-bottom:1px solid #FFFFFF;\
  1089. margin:0 auto;\
  1090. margin-top:50px;\
  1091. ',
  1092. insertIntoDoc: {
  1093. keyword: function() {
  1094. return document.getElementsByTagName("h2")[0].innerHTML.slice(19, -1);
  1095. },
  1096. target: 'css;.wrapper',
  1097. where: 'afterEnd'
  1098. }
  1099. },
  1100. {
  1101. name: "BTDigg",
  1102. url: /^https?:\/\/btdigg\.org\/search\?/,
  1103. enabled: true,
  1104. engineList: "download",
  1105. style: '\
  1106. margin:0 auto;\
  1107. border-top:1px solid #D4E9F7;\
  1108. border-bottom:1px solid #D4E9F7;\
  1109. ',
  1110. insertIntoDoc: {
  1111. keyword: 'css;input#searchq',
  1112. target: 'css;.pager',
  1113. where: 'beforeBegin'
  1114. }
  1115. },
  1116.  
  1117. //字幕
  1118. {
  1119. name: "subom",
  1120. url: /^https?:\/\/www\.subom\.net\/search/,
  1121. engineList: "download",
  1122. enabled: true,
  1123. style: "\
  1124. margin: 0px auto;\
  1125. ",
  1126. insertIntoDoc: {
  1127. keyword: 'css;#search_box',
  1128. target: 'css;#container',
  1129. where: 'afterBegin'
  1130. }
  1131. },
  1132. {
  1133. name: "subhd",
  1134. url: /^https?:\/\/subhd\.com\/search/,
  1135. engineList: "download",
  1136. enabled: true,
  1137. style: "\
  1138. text-align:center;\
  1139. display:block;\
  1140. top: -10px;\
  1141. ",
  1142. insertIntoDoc: {
  1143. keyword: 'css;#sn',
  1144. target: 'css;.container.list',
  1145. where: 'beforeBegin'
  1146. }
  1147. },
  1148. {
  1149. name: "射手网(伪)",
  1150. url: /^https?:\/\/sub\.makedie\.me\/sub\/\?searchword/,
  1151. engineList: "download",
  1152. enabled: true,
  1153. style: "\
  1154. text-align:center;\
  1155. margin:0 auto;\
  1156. ",
  1157. insertIntoDoc: {
  1158. keyword: 'css;b',
  1159. target: 'css;#site_header',
  1160. where: 'afterEnd'
  1161. }
  1162. },
  1163. // 购物
  1164. {
  1165. name: "一淘",
  1166. url: /^https?:\/\/s8?\.etao\.com\/search/,
  1167. enabled: true,
  1168. engineList: "shopping",
  1169. style: "\
  1170. border-top:1px solid #D4E9F7;\
  1171. border-bottom:1px solid #D4E9F7;\
  1172. margin:0 auto;\
  1173. word-break:keep-all;\
  1174. white-space:nowrap;\
  1175. ",
  1176. insertIntoDoc: {
  1177. keyword: 'css;#J_searchIpt',
  1178. target: 'css;#etao-header-bd',
  1179. where: 'beforeBegin'
  1180. }
  1181. },
  1182. {
  1183. name: "京东",
  1184. url: /^https?:\/\/search\.jd\.com\/(S|s)earch\?/i,
  1185. enabled: true,
  1186. engineList: "shopping",
  1187. style: "\
  1188. margin:0 auto;\
  1189. border-bottom:1px solid #E5E5E5;\
  1190. border-top:1px solid #E5E5E5;\
  1191. margin-bottom:3px;\
  1192. ",
  1193. insertIntoDoc: {
  1194. keyword: 'css;#key',
  1195. target: 'css;div[id*="nav-201"]',
  1196. where: 'beforeBegin'
  1197. }
  1198. },
  1199. {
  1200. name: "淘宝搜索",
  1201. url: /^https?:\/\/s\.taobao\.com\/search/,
  1202. enabled: true,
  1203. engineList: "shopping",
  1204. style: "\
  1205. width:100%;\
  1206. text-align:center;\
  1207. ",
  1208. insertIntoDoc: {
  1209. keyword: function() {
  1210. var input = document.querySelector('#q');
  1211. if (input) {
  1212. return input.value;
  1213. } else {
  1214. var m = location.search.match(/q=([^&]+)/);
  1215. if (m) {
  1216. return true;
  1217. }
  1218. }
  1219. },
  1220. target: 'css;body',
  1221. where: 'beforeBegin',
  1222. },
  1223. },
  1224. {
  1225. name: "易迅",
  1226. url: /^https?:\/\/searchex\.yixun\.com\/html\?/,
  1227. enabled: true,
  1228. engineList: "shopping",
  1229. style: "\
  1230. text-align: center;\
  1231. background-color:#FFFFFF;\
  1232. ",
  1233. insertIntoDoc: {
  1234. keyword: 'css;#q_show',
  1235. target: 'css;.ic_header',
  1236. where: 'beforeEnd'
  1237. }
  1238. },
  1239. {
  1240. name: "苏宁",
  1241. url: /^https?:\/\/(search)\.suning\.com\//,
  1242. enabled: true,
  1243. engineList: "shopping",
  1244. style: "\
  1245. border-top:1px solid #E5E5E5;\
  1246. margin:0 auto;\
  1247. ",
  1248. insertIntoDoc: {
  1249. keyword: 'css;#searchKeywords',
  1250. target: 'css;.g-header',
  1251. where: 'afterEnd'
  1252. }
  1253. },
  1254. {
  1255. name: "天猫",
  1256. url: /^https?:\/\/list\.tmall\.com\/\/?search/,
  1257. enabled: true,
  1258. engineList: "shopping",
  1259. style: "\
  1260. margin:0 auto;\
  1261. border-bottom:1px solid #E5E5E5;\
  1262. border-top:1px solid #E5E5E5;\
  1263. margin-bottom:3px;\
  1264. ",
  1265. insertIntoDoc: {
  1266. keyword: 'css;#mq',
  1267. target: 'css;#mallNav',
  1268. where: 'beforeBegin'
  1269. }
  1270. },
  1271. {
  1272. name: "亚马逊",
  1273. url: /^https?:\/\/www\.amazon\.cn\/s\/ref/,
  1274. enabled: true,
  1275. engineList: "shopping",
  1276. style: "\
  1277. border-top:1px solid #E5E5E5;\
  1278. ",
  1279. insertIntoDoc: {
  1280. keyword: 'css;#twotabsearchtextbox',
  1281. target: 'css;#navbar',
  1282. where: 'beforeEnd'
  1283. }
  1284. },
  1285. {
  1286. name: "当当",
  1287. url: /^https?:\/\/search\.dangdang\.com\/\?key/,
  1288. enabled: true,
  1289. engineList: "shopping",
  1290. style: "\
  1291. margin:0 auto;\
  1292. border-bottom:1px solid #E5E5E5;\
  1293. border-top:1px solid #E5E5E5;\
  1294. margin-bottom:3px;\
  1295. ",
  1296. insertIntoDoc: {
  1297. keyword: 'css;#key_S',
  1298. target: 'css;#bd',
  1299. where: 'beforeBegin'
  1300. }
  1301. },
  1302. {
  1303. name: "拍拍",
  1304. url: /^https?:\/\/s\.paipai\.com\/[a-z]/,
  1305. enabled: true,
  1306. engineList: "shopping",
  1307. style: "\
  1308. text-align:left;\
  1309. ",
  1310. insertIntoDoc: {
  1311. keyword: 'css;#KeyWord',
  1312. target: 'css;.mod_s',
  1313. where: 'beforeEnd'
  1314. }
  1315. },
  1316. {
  1317. name: "QQ网购",
  1318. url: /^https?:\/\/se?\.wanggou\.com\/[a-z]/,
  1319. enabled: true,
  1320. engineList: "shopping",
  1321. style: "\
  1322. margin:0 auto;\
  1323. background-color:#C8C8C8;\
  1324. border-bottom:1px solid #E5E5E5;\
  1325. border-top:1px solid #E5E5E5;\
  1326. margin-bottom:3px;\
  1327. ",
  1328. insertIntoDoc: {
  1329. keyword: 'css;#KeyWord',
  1330. target: 'css;.wg_header',
  1331. where: 'afterEnd'
  1332. }
  1333. },
  1334. {
  1335. name: "360购物",
  1336. url: /^https?:\/\/s\.mall\.360\.cn\/search/,
  1337. enabled: true,
  1338. engineList: "shopping",
  1339. style: "\
  1340. margin:0 auto;\
  1341. word-break:keep-all;\
  1342. white-space:nowrap;\
  1343. border-bottom:1px solid #E5E5E5;\
  1344. border-top:1px solid #E5E5E5;\
  1345. ",
  1346. insertIntoDoc: {
  1347. keyword: 'css;#mall_keyword',
  1348. target: 'css;.header',
  1349. where: 'afterEnd'
  1350. }
  1351. },
  1352.  
  1353. // 词典
  1354. {
  1355. name: "汉典",
  1356. url: /^https?:\/\/www\.zdic\.net\/sousuo/,
  1357. enabled: true,
  1358. engineList: "etc",
  1359. style: "\
  1360. word-break:keep-all;\
  1361. white-space:nowrap;\
  1362. margin:0 auto;\
  1363. border-bottom:1px solid #D4E9F7;\
  1364. border-top:1px solid #D4E9F7;\
  1365. ",
  1366. insertIntoDoc: {
  1367. keyword: 'css;#q',
  1368. target: 'css;.secpan',
  1369. where: 'afterEnd'
  1370. }
  1371. },
  1372. ];
  1373.  
  1374. if (typeof exports !== 'undefined') {
  1375. exports.rules = rules;
  1376. }
  1377.  
  1378. reloadDebug();
  1379.  
  1380. // --------------------可设置项结束------------------------
  1381.  
  1382. var debug;
  1383.  
  1384. function reloadDebug() {
  1385. debug = prefs.debug ? console.debug.bind(console) : function() {};
  1386. }
  1387.  
  1388. if (typeof String.prototype.startsWith != 'function') {
  1389. String.prototype.startsWith = function(str) {
  1390. return this.slice(0, str.length) == str;
  1391. };
  1392. }
  1393.  
  1394.  
  1395. function getPostFormHTML(url, args, newTab) {// 获取 method 为 POST 的表单的 HTML
  1396. var form = '<form method="post"' +
  1397. ' action="' + url + '"' +
  1398. (newTab ? ' target="_blank"' : '') +
  1399. '>';
  1400. for (var arg in args) {
  1401. var input = '<input type="hidden"' +
  1402. ' name="' + arg + '"' +
  1403. ' value="' + args[arg] + '"' +
  1404. ' />';
  1405. form += input;
  1406. }
  1407. form += '</form>';
  1408. return form;
  1409. }
  1410.  
  1411. function wrapToHide(html) {// 包装 HTML 元素代码以隐藏该元素
  1412. return '<span style="display:none;">' + html + '</span>';
  1413. }
  1414.  
  1415. function toRE(obj) {
  1416. if (obj instanceof RegExp) {
  1417. return obj;
  1418. } else if (obj instanceof Array) {
  1419. return new RegExp(obj[0], obj[1]);
  1420. } else {
  1421. return new RegExp(obj);
  1422. }
  1423. }
  1424.  
  1425. function getMStr(func) {
  1426. var lines = func.toString();
  1427. lines = lines.substring(lines.indexOf("/*") + 3, lines.lastIndexOf("*/"));
  1428. return lines;
  1429. }
  1430. //xpath 获取单个元素
  1431. /*function getElementByXPath(xPath, contextNode, doc) {
  1432. doc = doc || document;
  1433. contextNode = contextNode || doc;
  1434. return doc.evaluate(xPath, contextNode, null, 9, null).singleNodeValue;
  1435. };*/
  1436.  
  1437. // 事件支持检测.
  1438. // 比如 eventSupported('fullscreenchange', document);
  1439. function eventSupported(eventName, elem) {
  1440. elem = elem || document.createElement('div');
  1441. var prefix = ['o', 'ms', 'moz', 'webkit', ''];
  1442.  
  1443. var l = prefix.length;
  1444. var pEventName;
  1445. var isFunction;
  1446. var setAttr;
  1447.  
  1448. while(l --) {
  1449. pEventName = 'on' + prefix[l] + eventName;
  1450.  
  1451. if (pEventName in elem) return pEventName.slice(2);
  1452. else if (typeof elem.setAttribute == 'function') { // setAttribute 是元素节点的方法
  1453. setAttr = false;
  1454. if (!elem.hasAttribute(pEventName)) {
  1455. setAttr = true;
  1456. elem.setAttribute(pEventName, 'return;');
  1457. };
  1458.  
  1459. isFunction = typeof elem[pEventName] == 'function';
  1460.  
  1461. if (setAttr) elem.removeAttribute(pEventName);
  1462.  
  1463. if (isFunction) {
  1464. return pEventName.slice(2);
  1465. };
  1466. };
  1467. };
  1468.  
  1469. return false;
  1470. };
  1471.  
  1472.  
  1473. var data = (function () {// 保存指定对象相关数据
  1474. 'use strict';
  1475.  
  1476. var cache = {
  1477. objs: [],
  1478. data: {},
  1479. };
  1480.  
  1481.  
  1482. function data(obj, key, value) {
  1483. var id = cache.objs.indexOf(obj);
  1484. if (id == -1) {id = cache.objs.push(obj) - 1;};
  1485. if (!cache.data[id])cache.data[id] = {};//初始化
  1486. if (typeof value == 'undefined') {// 取值
  1487. return typeof key == 'undefined' ? cache.data[id] : cache.data[id][key];
  1488. } else {
  1489. return cache.data[id][key] = value;
  1490. };
  1491. };
  1492.  
  1493. return data;
  1494. })();
  1495.  
  1496. // 为mouseleave mouseenter事件做个兼容
  1497. // 需要 eventSupported, data函数支持
  1498. var mouseEventListener = (function () {
  1499.  
  1500. var support = {
  1501. mouseleave : eventSupported('mouseleave'),
  1502. mouseenter : eventSupported('mouseenter'),
  1503. };
  1504.  
  1505. var map = {
  1506. mouseleave : 'mouseout',
  1507. mouseenter : 'mouseover',
  1508. };
  1509.  
  1510. return {
  1511. add : function (type, ele, callback) { //事件类型,元素,监听函数
  1512. if (support[type]) {
  1513. ele.addEventListener(type, callback, false); //mouseleave,enter不冒泡,所以在冒泡阶段监听事件,不要担心子孙元素进出发生的事件冒泡上来。
  1514. } else {
  1515. var listener = data(callback, 'mouseELListener');
  1516. if (!listener) {
  1517. listener = function (e) {
  1518. var relatedTarget = e.relatedTarget; //mouseout,去往的元素;mouseover,来自的元素
  1519. // 当mouseout(离开ele)去往的元素不是自己的子孙元素
  1520. // 当mouseover(进入ele)来自的元素不是自己的子孙元素
  1521. if (!ele.contains(relatedTarget)) { // contains函数,自己.contains(自己) 返回true
  1522. callback.call(ele, e);
  1523. };
  1524. };
  1525. data(callback, 'mouseELListener', listener);
  1526. };
  1527.  
  1528. ele.addEventListener(map[type], listener, true);
  1529. };
  1530. },
  1531. remove : function (type, ele, callback) {
  1532. if (support[type]) {
  1533. ele.removeEventListener(type, callback, false);
  1534. } else {
  1535. ele.removeEventListener(map[type], data(callback, 'mouseELListener'), true);
  1536. };
  1537. },
  1538. };
  1539. })();
  1540.  
  1541.  
  1542. function getScrolled(container) {//获取已滚动的距离
  1543. if (container) {
  1544. return {
  1545. x:container.scrollLeft,
  1546. y:container.scrollTop,
  1547. };
  1548. };
  1549. return {
  1550. x: 'scrollX' in window ? window.scrollX : ('pageXOffset' in window ? window.pageXOffset : document.documentElement.scrollLeft || document.body.scrollLeft),
  1551. y: 'scrollY' in window ? window.scrollY : ('pageYOffset' in window ? window.pageYOffset : document.documentElement.scrollTop || document.body.scrollTop),
  1552. };
  1553. };
  1554.  
  1555. function getElement(selector) {
  1556. if (selector.indexOf('css;') == 0) {
  1557. return document.querySelector(selector.slice(4));
  1558. } else {
  1559. return "";
  1560. };
  1561. };
  1562.  
  1563. function toUTF16(str) { //说是UTF16,但其实是dA专用的,是对转义字符进行编码
  1564. var length = str.length;
  1565. var ret = [];
  1566. var character;
  1567. var charCode;
  1568. var gCode;
  1569. var neReg = /[\dA-z]/;
  1570. for (var i = 0; i < length; i++) {
  1571. charCode = str.charCodeAt(i);
  1572. if (charCode <= 128) {
  1573. character = str.charAt(i);
  1574. if (neReg.test(character)) { /*ascii的数字字母不编码*/
  1575. ret.push(character);
  1576. } else {
  1577. ret.push('%' + charCode.toString(16));
  1578. };
  1579. } else {
  1580. gCode = charCode.toString();
  1581. if (gCode) {
  1582. while (gCode.length < 4) {
  1583. gCode = '0' + gCode;
  1584. };
  1585. ret.push('%26%23' + gCode + '%3B');
  1586. } else {
  1587. /*字库里面没有.*/
  1588. };
  1589. };
  1590. };
  1591. return ret.join('');
  1592. };
  1593.  
  1594.  
  1595. function parseDataStr(str, opt) {// 转换文本数据为 engineList 对象
  1596. if (typeof opt == 'undefined') {
  1597. opt = {};
  1598. }
  1599.  
  1600.  
  1601. str = str.replace(/[\n\r]+[\s\/]*-\s*(\S+):/g, '_POST_ $1:');// 提前处理下特殊的 post 方式
  1602.  
  1603. var parseArgs = function(str) {
  1604. var arr = str.replace(/,/g, ', ').split(/\s*, \s*/);
  1605. var args = {};
  1606. arr.forEach(function(s){
  1607. var argArr = s.split(/\s*: \s*/);
  1608. args[argArr[0]] = argArr[1];
  1609. });
  1610. return args;
  1611. };
  1612.  
  1613. var isEncoding = function(str) {
  1614. str = str.trim().toLowerCase();
  1615. return ['utf-8', 'gb', 'utf16'].some(function(e) {
  1616. return str.indexOf(e) == 0;
  1617. });
  1618. };
  1619.  
  1620. var parseLine = function (line) {
  1621. line = line.trim();
  1622.  
  1623. if (!line) return;
  1624.  
  1625. if (line.indexOf('//') == 0) {
  1626. if (opt.commentLine) line = line.replace(/^\/\/\s*/, '');// 包含注释行
  1627. else return;
  1628. }
  1629.  
  1630. var engine = {};
  1631.  
  1632. if (line.indexOf('_POST_') != -1) {
  1633. engine.method = 'POST';
  1634. var two = line.split(/\s*_POST_\s*/);
  1635. line = two[0];
  1636. engine.args = parseArgs(two[1]);
  1637. }
  1638.  
  1639. var arr = line.replace(/,/g, ', ').split(/\s*, \s*/);
  1640. if (arr.length === 1) { // 分类
  1641. return line;
  1642. }
  1643.  
  1644. engine.name = arr[0];
  1645. engine.url = arr[1];
  1646. engine.host = parseUri(engine.url).host;
  1647.  
  1648. // 处理编码和图标
  1649. if (arr[2] && isEncoding(arr[2])) {
  1650. engine.encoding = arr[2];
  1651. engine.favicon = arr[3];
  1652. } else {
  1653. engine.favicon = arr[2];
  1654. }
  1655.  
  1656. if (!engine.favicon) {
  1657. engine.favicon = getFaviconUrl(engine.url, opt.iconType);
  1658. }
  1659.  
  1660. return engine;
  1661. };
  1662.  
  1663. var list = {},
  1664. type;
  1665.  
  1666. str.split(/[\n\r]+/).forEach(function(line){
  1667. var engine = parseLine(line);
  1668. if (!engine) {
  1669. return;
  1670. }
  1671.  
  1672. if (typeof engine === 'string') {
  1673. type = line.trim();
  1674. list[type] = [];
  1675. } else list[type].push(engine);
  1676. });
  1677.  
  1678. return list;
  1679. }
  1680.  
  1681. function getFaviconUrl(url, type) {
  1682. var uri = parseUri(url);
  1683. switch(type) {
  1684. case 0:
  1685. return 'https://www.google.com/s2/favicons?domain=' + uri.host;
  1686. default:
  1687. return uri.protocol + '://' + uri.host + '/favicon.ico';
  1688. }
  1689. }
  1690.  
  1691. // parseUri 1.2.2
  1692. // (c) Steven Levithan <stevenlevithan.com>
  1693. // MIT License
  1694. var parseUri = function(str) {
  1695. var o = parseUri.options,
  1696. m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
  1697. uri = {},
  1698. i = 14;
  1699.  
  1700. while (i--) uri[o.key[i]] = m[i] || "";
  1701.  
  1702. uri[o.ds.name] = {};
  1703. uri[o.ds.name][0] = {};
  1704. uri[o.ds.name][0]['key'] = (uri.protocol ? uri.protocol : 'http') + '://' + uri.host + (uri.port ? ':' + uri.port : '') + '/';
  1705. uri[o.ds.name][0]['val'] = '/';
  1706. var i = 0,
  1707. tempsub = '/',
  1708. subs = uri[o.key[10]].substr(1).split('/');
  1709. for (var j = 1; j < (subs.length + 1); j++, i++) {
  1710. tempsub += tempsub === '/' ? subs[i] : '/' + subs[i];
  1711. if (subs[i]) {
  1712. uri[o.ds.name][j] = {};
  1713. uri[o.ds.name][j]['key'] = subs[i];
  1714. uri[o.ds.name][j]['val'] = tempsub;
  1715. }
  1716. }
  1717.  
  1718. uri[o.q.name] = {};
  1719. uri[o.key[12]].replace(o.q.parser, function($0, $1, $2) {
  1720. if ($1) uri[o.q.name][$1] = $2;
  1721. });
  1722. uri[o.aq.name] = {};
  1723. uri[o.key[13]].replace(o.aq.parser, function($0, $1, $2) {
  1724. if ($1) uri[o.aq.name][$1] = $2;
  1725. });
  1726.  
  1727. return uri;
  1728. };
  1729. parseUri.options = {
  1730. strictMode: false,
  1731. key: ["source", "protocol", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor"],
  1732. q: {
  1733. name: "queryKey",
  1734. parser: /(?:^|&)([^&=]*)=?([^&]*)/g
  1735. },
  1736. aq: {
  1737. name: "anchorqueryKey",
  1738. parser: /(?:^|&)([^&=]*)=?([^&]*)/g
  1739. },
  1740. ds: {
  1741. name: "directorySub"
  1742. },
  1743. parser: {
  1744. strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
  1745. loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
  1746. }
  1747. };
  1748.  
  1749. if (typeof exports !== 'undefined') {
  1750. exports.parseDataStr = parseDataStr;
  1751. exports.parseUri = parseUri;
  1752. }
  1753.  
  1754. function DropDownList(a, list) {// 列表对象
  1755. this.a = a;
  1756. this.list = list;
  1757. this.init();
  1758. };
  1759. DropDownList.zIndex = 100000000;
  1760.  
  1761. DropDownList.prototype = {
  1762. hidden: true,
  1763. showDelay: 233,
  1764. hideDelay: 266,
  1765. aShownClass: 'sej-drop-list-trigger-shown',
  1766.  
  1767. init: function () {
  1768. var a = this.a;
  1769. var list = this.list;
  1770. var self = this;
  1771.  
  1772. mouseEventListener.add('mouseenter', a, function () {// 进入显示
  1773. clearTimeout(self.hideTimerId);
  1774.  
  1775. if (self.hidden) {
  1776. self.showTimerId = setTimeout(function () {
  1777. self.show();
  1778. }, self.showDelay);
  1779. } else {
  1780. var style = list.style;
  1781. style.zIndex = DropDownList.zIndex ++;
  1782. style.opacity = 0.96;
  1783. };
  1784. });
  1785.  
  1786. // 离开隐藏
  1787. mouseEventListener.add('mouseleave', a, function () {
  1788. clearTimeout(self.showTimerId);
  1789.  
  1790. if (!self.hidden) {
  1791. list.style.opacity = 0.3;
  1792. self.hideTimerId = setTimeout(function () {
  1793. self.hide();
  1794. }, self.hideDelay);
  1795. };
  1796. });
  1797.  
  1798. mouseEventListener.add('mouseenter', list, function () {
  1799. clearTimeout(self.hideTimerId);
  1800.  
  1801. var style = list.style;
  1802. style.zIndex = DropDownList.zIndex ++;
  1803. style.opacity = 0.96;
  1804. });
  1805.  
  1806. mouseEventListener.add('mouseleave', list, function () {
  1807.  
  1808. list.style.opacity = 0.3;
  1809. self.hideTimerId = setTimeout(function () {
  1810. self.hide();
  1811. }, self.hideDelay);
  1812. });
  1813. },
  1814. show: function () {
  1815. if (!this.hidden) return;
  1816. this.hidden = false;
  1817.  
  1818. var scrolled = getScrolled();
  1819. var aBCRect = this.a.getBoundingClientRect();
  1820.  
  1821. var style = this.list.style;
  1822.  
  1823. var top, left;
  1824. if (this.a.dataset.horizontal) { // 向右展开
  1825. top = scrolled.y + aBCRect.top;
  1826. left = scrolled.x + aBCRect.left + this.a.clientWidth;
  1827. } else { // 默认的向下展开
  1828. top = scrolled.y + aBCRect.bottom;
  1829. left = scrolled.x + aBCRect.left;
  1830. }
  1831.  
  1832. left=left-25;//使用居中样式的调整
  1833. style.top = top + 6 + 'px';
  1834. style.left = left + 'px';
  1835. style.zIndex = DropDownList.zIndex ++;
  1836. style.display = 'block';
  1837.  
  1838. setTimeout(function () {
  1839. style.opacity = 0.96;
  1840. style.top = top + 'px';
  1841. }, 30);
  1842.  
  1843. this.a.classList.add(this.aShownClass);
  1844.  
  1845. },
  1846. hide: function () {
  1847. if (this.hidden) return;
  1848. this.hidden = true;
  1849.  
  1850. var style = this.list.style;
  1851. style.display = 'none';
  1852. style.opacity = 0.3;
  1853.  
  1854. this.a.classList.remove(this.aShownClass);
  1855.  
  1856. },
  1857. };
  1858.  
  1859. function addGlobalStyle() {
  1860. // 添加全局样式和自定义样式
  1861. var style = document.getElementById('sej-style');
  1862. if (!style) {
  1863. style = document.createElement('style');
  1864. style.id = 'sej-style';
  1865. style.type = 'text/css';
  1866. style.textContent = MAIN_CSS + '\n' + (matchedRule.stylish || '');
  1867. document.head.appendChild(style);
  1868. }
  1869. }
  1870.  
  1871. function addContainer(iTarget, iInput) {
  1872. var pageEncoding = (document.characterSet || document.charset).toLowerCase();
  1873. // 创建dom
  1874. var aPattern = '<a href="" class="sej-engine"' + (prefs.openInNewTab ? ' target="_blank" ' : ' ') +
  1875. 'encoding="$encoding$" url="$url$" onclick="$onclick$" _title="$title$">' +
  1876. '<img src="$favicon$" class="sej-engine-icon" />$form$<span>$name$</span></a>';
  1877.  
  1878. var container = document.createElement('sejspan');
  1879. container.id = 'sej-container';
  1880.  
  1881. container.addEventListener('mousedown', mousedownhandler, true);
  1882. if (matchedRule.style) {
  1883. container.style.cssText = matchedRule.style;
  1884. }
  1885.  
  1886. var dropLists = [];
  1887.  
  1888. // 根据搜索列表的类型得到数据
  1889. var engineListDataStr = engineListData[prefs.engineListDataType] || engineListData.normal;
  1890. var allEngineList = parseDataStr(engineListDataStr);
  1891. var isFirstDropList = true;
  1892. var isMatched = false; // 当前搜索只匹配一次
  1893.  
  1894. Object.keys(allEngineList).forEach(function (categoryStr) {
  1895. var categoryArr = categoryStr.split('-');
  1896.  
  1897. var category = {
  1898. str: categoryStr,
  1899. name: categoryArr[0],
  1900. icon: categoryArr[1],
  1901. insert: categoryArr[2]
  1902. };
  1903.  
  1904. var engines = [];
  1905.  
  1906. var engineList = allEngineList[categoryStr];
  1907. engineList.forEach(function (engine) {
  1908. if (matchedRule.engineList && !isMatched && toRE(matchedRule.url).test(engine.url)) { // 去掉跳转到当前引擎的引擎
  1909. isMatched = true; // 去除当前搜索只匹配一次
  1910. return;
  1911. }
  1912.  
  1913. var a = aPattern.replace('$encoding$', (engine.encoding || 'utf-8').toLowerCase())
  1914. .replace('$url$', engine.url)
  1915. .replace('$name$', engine.name)
  1916. .replace('$title$', engine.name);
  1917. if (engine.favicon) {
  1918. a = a.replace('$favicon$', engine.favicon);
  1919. } else {
  1920. a = a.replace('src="$favicon$"', '');
  1921. }
  1922.  
  1923. if (engine.method && engine.method.toUpperCase() == 'POST') {
  1924. var f = wrapToHide(getPostFormHTML(engine.url, engine.args, prefs.openInNewTab));
  1925. a = a.replace('$form$', f);
  1926. a = a.replace('$onclick$', "this.getElementsByTagName('form')[0].submit();return false;");
  1927. } else {
  1928. a = a.replace('$form$', '');
  1929. a = a.replace('onclick="$onclick$"', '');
  1930. }
  1931.  
  1932. engines.push(a);
  1933. });
  1934.  
  1935. // 非空列表
  1936. if (!engines.length) return;
  1937.  
  1938. // 插入一个节点给 insertBefore 用
  1939. var lastInsertTitle = category.name;
  1940. engines = engines.join('') + '<span class="sej-engine" _title="' + lastInsertTitle + '" style="display: none;"></span>';
  1941.  
  1942. if (isTheSameCategory(category.name, matchedRule.engineList)) {
  1943. container.innerHTML = '<sejspan id="sej-expanded-category">'+ category.name +'</sejspan>' + engines;
  1944. } else {
  1945. var dropList = document.createElement('sejspan');
  1946. dropList.className = 'sej-drop-list';
  1947. dropList.innerHTML = engines;
  1948.  
  1949. // 有子 droplist
  1950. var a = dropList.firstElementChild.cloneNode(true);
  1951. a.className = a.className + ' sej-drop-list-trigger';
  1952. a.lastChild.textContent = category.name;
  1953.  
  1954. // 更改图标
  1955. if (category.icon) {
  1956. var e = engineList[category.icon - 1];
  1957. if (e && e.favicon) { // 数字匹配
  1958. a.firstChild.src = e.favicon;
  1959. } else { // 名称匹配
  1960. for (var i = 0; i < engineList.length; i++) {
  1961. if (engineList[i].name == category.icon) {
  1962. a.firstChild.src = engineList[i].favicon;
  1963. break;
  1964. }
  1965. };
  1966. }
  1967. }
  1968.  
  1969. // 是否为第一个 droplist
  1970. if (isFirstDropList) {
  1971. a.className += ' first';
  1972. isFirstDropList = false;
  1973. }
  1974.  
  1975. // 重新插入的位置
  1976. if (typeof category.insert !== 'undefined') {
  1977. a.dataset.horizontal = true;
  1978. a.dataset.insert = category.insert;
  1979. }
  1980.  
  1981. dropLists.push({
  1982. a: a,
  1983. dropList: dropList
  1984. });
  1985. };
  1986. });
  1987.  
  1988. dropLists.forEach(function (item, index) {
  1989. var a = item.a,
  1990. dropList = item.dropList;
  1991.  
  1992. // 移到某个类别里面
  1993. var ins;
  1994. var insert = a.dataset.insert;
  1995. if (typeof insert !== 'undefined') {
  1996. ins = document.querySelector('.sej-engine[_title="' + insert + '"]:not(.sej-drop-list-trigger)');
  1997. }
  1998.  
  1999. if (ins) {
  2000. ins.parentNode.insertBefore(a, ins);
  2001. } else {
  2002. container.appendChild(a);
  2003. }
  2004.  
  2005. if (a.dataset.horizontal && a.parentNode.id === container.id) { // 如果是顶层,菜单不需要修正
  2006. a.removeAttribute('data-horizontal');
  2007.  
  2008. // 插入到第一个类别前面
  2009. // ins = container.querySelector('a.sej-engine.first');
  2010. ins = container.querySelector('a.sej-engine:not(.sej-drop-list-trigger)');
  2011. ins.parentNode.insertBefore(a, ins);
  2012. }
  2013.  
  2014. if (prefs.position == 'left') { // 如果再左边的话,修正弹出菜单的位置
  2015. a.dataset.horizontal = true;
  2016. }
  2017. document.body.appendChild(dropList);
  2018.  
  2019. dropList.addEventListener('mousedown', mousedownhandler, true);
  2020.  
  2021. new DropDownList(a, dropList);
  2022. });
  2023.  
  2024. var insertWhere = matchedRule.insertIntoDoc.where;// 设置插入的位置
  2025.  
  2026. switch (insertWhere.toLowerCase()) {// 插入到文档中
  2027. case 'beforebegin' :
  2028. iTarget.parentNode.insertBefore(container, iTarget);
  2029. break;
  2030. case 'afterbegin' :
  2031. if (iTarget.firstChild) {
  2032. iTarget.insertBefore(container, iTarget.firstChild);
  2033. } else {
  2034. iTarget.appendChild(container);
  2035. }
  2036. break;
  2037. case 'beforeend' :
  2038. iTarget.appendChild(container);
  2039. break;
  2040. case 'afterend' :
  2041. if (iTarget.nextSibling) {
  2042. iTarget.parentNode.insertBefore(container, iTarget.nextSibling);
  2043. } else {
  2044. iTarget.parentNode.appendChild(container);
  2045. }
  2046. break;
  2047.  
  2048. };
  2049.  
  2050. var isTwoLine = container.clientHeight / container.children[1].clientHeight > 2;
  2051.  
  2052. // 插入后调整下,如果变成两行,隐藏文字
  2053. if (prefs.hideEnglineLabel == 2 || (prefs.hideEnglineLabel == 1 && isTwoLine)) {
  2054. [].forEach.call(document.querySelectorAll('#sej-container > a[class="sej-engine"] > span'), function(span) {
  2055. var link = span.parentNode;
  2056. link.classList.add('only-icon');
  2057. link.setAttribute('title', span.textContent);
  2058. });
  2059. }
  2060.  
  2061. if (typeof matchedRule.endFix == 'function') {
  2062. try {
  2063. matchedRule.endFix();
  2064. } catch(ex) {
  2065. console.error('endFix 错误', ex);
  2066. }
  2067. }
  2068.  
  2069. function mousedownhandler(e) {
  2070. var target = e.target;
  2071. if(!target.href)target = target.parentNode;
  2072.  
  2073. // if (!target || target.className.indexOf('sej-engine') == -1) return;
  2074. if (!target || !this.contains(target)) return;
  2075.  
  2076. var value;
  2077. if (typeof iInput == 'function') value = iInput();
  2078. else {
  2079. if (iInput.nodeName == 'INPUT' || iInput.localName == 'textarea') value = iInput.value;
  2080. else value = iInput.textContent;
  2081. }
  2082.  
  2083. // 根据后代元素中是否存在 form 元素,判断提交方式并进行处理
  2084. // 如果没有 form 元素,将会使用 GET 方法提交;如果有,将会使用 POST 方法提交
  2085. var forms = target.getElementsByTagName('form');
  2086. if (forms.length == 0) { // 提交方式为 GET
  2087. // 处理编码
  2088. var encoding = target.getAttribute('encoding');
  2089. if (encoding == 'utf-8') value = encodeURIComponent(value);
  2090. else if (encoding.indexOf('gb') == 0) console.log('不再收录gbk编码的引擎')
  2091. else if (encoding == 'utf16') value = toUTF16(value);
  2092.  
  2093. target.href = target.getAttribute('url').replace(/%s/g, value); // 替换“全部”关键词
  2094. }
  2095. else{ // 提交方式为 POST
  2096. var inputs = target.getElementsByTagName('input');
  2097. for (var i = 0; i < inputs.length; i++) inputs[i].value = inputs[i].value.replace(/%s/g, value); // // 替换“全部”关键词
  2098. }
  2099. }
  2100. }
  2101.  
  2102. function run() {
  2103. // 百度搜索插入到顶部搜索条下面就会造成页面部分元素的消失,所以需要每个部分都判断下是否存在
  2104. // 判断插入位置和输入框是否存在
  2105. var iTarget = getElement(matchedRule.insertIntoDoc.target);
  2106. var iInput;
  2107. if (typeof matchedRule.insertIntoDoc.keyword == 'function') {
  2108. iInput = matchedRule.insertIntoDoc.keyword;
  2109. if (!iInput()) {
  2110. return;
  2111. }
  2112. } else {
  2113. iInput = getElement(matchedRule.insertIntoDoc.keyword);
  2114. }
  2115. debug('插入的位置为 %o', iTarget);
  2116. debug('匹配的输入框为 %o', iInput);
  2117.  
  2118. if (!iTarget || !iInput) {
  2119. debug('不存在插入的位置或匹配的输入框', iTarget, iInput);
  2120. return;
  2121. }
  2122.  
  2123. addGlobalStyle();
  2124.  
  2125. // 判断是否存在
  2126. var container = document.getElementById('sej-container'),
  2127. sejspan = document.querySelector('sejspan.sej-drop-list');
  2128.  
  2129. if (!container || !sejspan) {
  2130. if (container) {
  2131. container.parentNode.removeChild(container);
  2132. }
  2133. addContainer(iTarget, iInput);
  2134. }
  2135. }
  2136.  
  2137. function remove() {
  2138. var elems = document.querySelectorAll('#sej-container, sejspan.sej-drop-list');
  2139. if (!elems) return;
  2140.  
  2141. [].forEach.call(elems, function(elem) {
  2142. elem.parentNode.removeChild(elem);
  2143. });
  2144. }
  2145.  
  2146. // iframe 禁止加载
  2147. if (window.self != window.top) return;
  2148.  
  2149. var matchedRule;
  2150.  
  2151. rules.some(function (rule) {
  2152. if (toRE(rule.url).test(location.href)) {
  2153. matchedRule = rule;
  2154. if (typeof rule.etc == 'function') {
  2155. try {
  2156. rule.etc();
  2157. } catch(ex) {
  2158. console.error('执行 etc 错误', ex);
  2159. }
  2160. }
  2161. return true;
  2162. };
  2163. });
  2164.  
  2165.  
  2166. debug('匹配的规则为', matchedRule);
  2167.  
  2168. if (!matchedRule || !matchedRule.enabled) return;
  2169.  
  2170. run();
  2171.  
  2172. if (matchedRule.mutationTitle) {
  2173. debug('添加标题节点监视器: title');
  2174.  
  2175. var watch = document.querySelector('title');
  2176. var observer = new MutationObserver(function(mutations){
  2177. debug('标题发生了变化', document.title);
  2178. run();
  2179. });
  2180. observer.observe(watch, {childList: true, subtree: true, characterData: true});
  2181. }
  2182.  
  2183.  
  2184. })()

QingJ © 2025

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