NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name csdn复制公式到word // @namespace http://blog.csdn.net // @version 0.1 // @description csdn复制公式,点菜单公式按钮,手动选中复制,word右键粘贴只保留文本,Axmath公式转换,将latex代码转换为axmath公式 // @author mikecoding // @match https://blog.csdn.net/* // @copyright 2021, mikecoding (https://openuserjs.org/users/mikecoding) // @require http://code.jquery.com/jquery-1.11.0.min.js // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; jQuery.fn.wait = function (selector, func, times, interval) { var _times = times || -1, //100次 _interval = interval || 20, //20毫秒每次 _self = this, _selector = selector, //选择器 _iIntervalID; //定时器id if (this.length) { //如果已经获取到了,就直接执行函数 func && func.call(this); } else { _iIntervalID = setInterval(function () { if (!_times) { //是0就退出 clearInterval(_iIntervalID); } _times <= 0 || _times--; //如果是正数就 -- _self = $(_selector); //再次选择 if (_self.length) { //判断是否取到 func && func.call(_self); clearInterval(_iIntervalID); } }, _interval); } return this; } $(".toolbar-container").wait(".toolbar-container", function () { console.log("加载成功"); $('<li class="" title="公式"><a href="javascript:;" style="color:green" class="copytax Button--blue">公式转换</a></li>').appendTo($("ul[class^='toolbar-menus']")); $(".copytax").click(function () { console.log("运行成功"); for (var i = 0; i < document.getElementsByClassName("katex-html").length; i++) { document.getElementsByClassName("katex-html")[i].innerHTML = ""; } for (i = 0; i < document.getElementsByClassName("katex-mathml").length; i++) { document.getElementsByClassName("katex-mathml")[i].innerHTML = "$$" + document.getElementsByClassName("katex-mathml")[i].innerHTML.trim().split("\n").pop().trim() + "$$" } }); }) })();