您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
双击以复制 Latex 公式代码。
当前为
// ==UserScript== // @name Zhihu Latex 公式复制 // @name:en Zhihu Latex Copy // @namespace http://tampermonkey.net/ // @version 0.1.5 // @description 双击以复制 Latex 公式代码。 // @description:en Double click to copy latex codes of formulas. // @author PRO // @match https://zhuanlan.zhihu.com/* // @icon http://zhihu.com/favicon.ico // @grant none // @license gpl-3.0 // @require https://greasyfork.org/scripts/462234-message/code/Message.js?version=1192786 // ==/UserScript== (function() { 'use strict'; let name = 'Zhihu Latex Copy'; window.QMSG_GLOBALS = { DEFAULTS: { showClose:true, timeout: 2000 } } let toast = (s, error=false) => { if (error) { Qmsg.error(`[${name}] ${s}`); console.error(`[${name}] ${s}`); } else { Qmsg.success(`[${name}] ${s}`); console.log(`[${name}] ${s}`); } }; let emojis = ["🥳", "😘", "😇", "😉"]; let random_emoji = () => { return emojis[Math.floor(Math.random() * emojis.length)]; }; let nodes = document.querySelectorAll("span.ztext-math"); nodes.forEach(node => { node.title = "Double click to copy: " + node.attributes.getNamedItem("data-tex").value; node.addEventListener("dblclick", e => { let latex = node.attributes.getNamedItem("data-tex").value; navigator.clipboard.writeText(latex); toast(random_emoji() + " Copied!"); }); }); })();