维基增强

维基增强搜索和公式复制

// ==UserScript==
// @name         维基增强
// @namespace    http://tampermonkey.net/
// @version      0.0.1
// @description  维基增强搜索和公式复制
// @author       [email protected]
// @license      MIT
// @match        *://chat.openai.com/*
// @match        *://*.wikipedia.org/*
// @match        *://baike.baidu.com/*
// @match        *://www.zhihu.com/*
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/3.6.4/jquery.min.js
// @icon         https://api.iconify.design/logos:xwiki-icon.svg
// @grant        none
// ==/UserScript==

(function () {
  "use strict";
  var jq = $.noConflict(true);
  window.MathJax = {
    tex: {
      inlineMath: [
        ["$", "$"],
        ["\\(", "\\)"],
      ],
      forceReparse: true,
    },
    svg: { fontCache: "global" },
  };
  jq("head").append("<script async src='https://cdn.bootcdn.net/ajax/libs/mathjax/3.2.2/es5/tex-svg.min.js'></script>");
  // 百度百科
  jq("#searchForm > .input-wrap").css("width", "424px");
  jq("#searchForm > #search").after("<button class='baidubaike-wiki' type='button'>维基百科</button>");
  jq(".baidubaike-wiki").on({
    click: function () {
      window.open("https://zh.wikipedia.org/wiki/" + jq("#query").val());
      return false;
    },
  });
  // 知乎
  jq(".SearchBar-searchButton").before(
    '<span class="zhihu-wiki" style="display:grid;place-items:center;cursor:pointer;"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" d="m14.97 18.95l-2.56-6.03c-1.02 1.99-2.14 4.08-3.1 6.03c-.01.01-.47 0-.47 0C7.37 15.5 5.85 12.1 4.37 8.68C4.03 7.84 2.83 6.5 2 6.5v-.45h5.06v.45c-.6 0-1.62.4-1.36 1.05c.72 1.54 3.24 7.51 3.93 9.03c.47-.94 1.8-3.42 2.37-4.47c-.45-.88-1.87-4.18-2.29-5c-.32-.54-1.13-.61-1.75-.61c0-.15.01-.25 0-.44l4.46.01v.4c-.61.03-1.18.24-.92.82c.6 1.24.95 2.13 1.5 3.28c.17-.34 1.07-2.19 1.5-3.16c.26-.65-.13-.91-1.21-.91c.01-.12.01-.33.01-.43c1.39-.01 3.48-.01 3.85-.02v.42c-.71.03-1.44.41-1.82.99L13.5 11.3c.18.51 1.96 4.46 2.15 4.9l3.85-8.83c-.3-.72-1.16-.87-1.5-.87v-.45l4 .03v.42c-.88 0-1.43.5-1.75 1.25c-.8 1.79-3.25 7.49-4.85 11.2h-.43Z"/></svg></span>'
  );
  jq(".zhihu-wiki").on({
    click: function () {
      window.open("https://zh.wikipedia.org/wiki/" + jq(".SearchBar-input .Input").val());
      return false;
    },
  });
  // Your code here...
})();