百度搜索懒人辅助列表

本脚本功能:作用于https://www.baidu.com/*,增加一个搜索列表,可快速对列表里的站点进行搜索。本脚本永久开源,永久免费。本脚本不得被用于任何的非法用途,仅能被合法的学习和使用。如果您安装了本脚本,产生的一切后果均由您承担,本人概不负责。本脚本的后续更新与否只取决于本人的心情。

目前為 2021-11-21 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name 百度搜索懒人辅助列表
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.02
  5. // @license MIT
  6. // @description 本脚本功能:作用于https://www.baidu.com/*,增加一个搜索列表,可快速对列表里的站点进行搜索。本脚本永久开源,永久免费。本脚本不得被用于任何的非法用途,仅能被合法的学习和使用。如果您安装了本脚本,产生的一切后果均由您承担,本人概不负责。本脚本的后续更新与否只取决于本人的心情。
  7. // @author zqdlly
  8. // @match https://www.baidu.com/*
  9. // @run-at document-idle
  10.  
  11. // ==/UserScript==
  12. function 添加样式(css,id='') {//植入css
  13. const style = document.createElement('style');
  14. style.type='text/css';
  15. id!=''?style.id = id:0;
  16. style.textContent = css;
  17. const h0 =document.querySelector('html');
  18. h0.insertBefore(style,h0.children[0]);
  19. }
  20. function 插入元素(父亲,标签,内容) {//插入元素(document.body,'标签','内容','idk','true');插入元素(document.head,'标签','内容','idk','true',1);
  21. const 新元素 = document.createElement(标签)
  22. 新元素.appendChild(document.createTextNode(内容));
  23. let 插入位置=0;
  24. let = arguments.length
  25. if (长>3) {
  26. if(长%2==0){//如果是偶数
  27. 插入位置=arguments[长-1]
  28. 长--
  29. }
  30. for(let i=3;i<长;i+=2){
  31. 新元素.setAttribute([arguments[i]],arguments[i+1])
  32. }
  33. }
  34. return 父亲.insertBefore(新元素,父亲.children[插入位置])
  35. }
  36. 添加样式(`.head_nums_cont_inner{top: 0px!important;}.my{z-index:9999;height:40px}#page{position: fixed!important;top: 50%;right: 35px;}`);
  37. 插入元素(document.head,'script',
  38. `
  39. function changer (e){
  40. const n = e.options[e.selectedIndex].value;
  41. const o = queryReplace("site");
  42. if ("" == n){
  43. ns_c({
  44. fm: "advTool",
  45. qid: bds.comm.qid,
  46. title: encodeURI("站内检索:" + n),
  47. rsv_advTool_si: encodeURI(n)
  48. });
  49. baseChangeUrl("wd=" + encodeURIComponent(o) + "&si=&ct=0")
  50. }
  51. else {
  52. if (!n.match(/^[\\w\\-_]+(.[\\w\\-_]+)+$/)) {
  53. //$(".c-tip-timerfilter-si-error").show();
  54. return;
  55. }
  56. //$(".c-tip-timerfilter-si-error").hide()
  57. ns_c({
  58. fm: "advTool",
  59. qid: bds.comm.qid,
  60. title: encodeURI("站内检索:" + n),
  61. rsv_advTool_si: encodeURI(n)
  62. });
  63. baseChangeUrl("wd=" + encodeURIComponent(o) + "&si=" + encodeURIComponent(n) + "&ct=2097152")
  64. }
  65. e.children[0].selected = true;
  66. }
  67. `);
  68.  
  69. const documentFragment = document.createDocumentFragment();
  70.  
  71. const ul = document.createElement('select');
  72. ul.setAttribute('class','my');
  73. ul.id='myselecyor';
  74. ul.setAttribute('onchange','changer(this)');
  75.  
  76.  
  77. /*
  78. */
  79. //site:tieba.baidu.com
  80. const data = {' ':' ',知乎:'zhihu.com',贴吧:'tieba.baidu.com',豆瓣:'douban.com',菜鸟教程:'runoob.com',吾爱破解:'52pojie.cn',CSDN:'csdn.net',虎扑论坛:'bbs.hupu.com',百度知道:'zhidao.baidu.com',博客园:'cnblogs.com',百度网盘:'pan.baidu.com',bilibili:'bilibili.com',微博:'weibo.com',脚本之家:'jb51.net',谷歌:'google.com'};
  81. const len=data.length;
  82.  
  83. for (const key in data) {
  84. //alert(key + '=' + data[key]);
  85. const li = document.createElement('option');
  86. li.innerText=key;
  87. li.value=data[key];
  88. documentFragment.appendChild(li);
  89. }
  90. ul.appendChild(documentFragment);
  91. document.querySelector('.tools').appendChild(ul);
  92.  
  93.