Greasy Fork镜像 支持简体中文。

向 latexlive.com 添加复制按钮

向 latexlive.com 添加复制按钮,方便快速复制 latex

  1. // ==UserScript==
  2. // @name 向 latexlive.com 添加复制按钮
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description 向 latexlive.com 添加复制按钮,方便快速复制 latex
  6. // @author Cesaryuan
  7. // @match https://*.latexlive.com/*
  8. // @icon https://www.google.com/s2/favicons?domain=latexlive.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15. // create a new button
  16. var btn = document.createElement('button');
  17. btn.innerHTML = '复制';
  18. // add class to btn
  19. btn.className = 'btn btn-light theme-fill';
  20. // set id
  21. btn.id = 'copy-btn';
  22. // add click handler
  23. btn.onclick = function () {
  24. // get the selected element
  25. var selected = document.querySelector('#txta_input');
  26. // copy the text
  27. navigator.clipboard.writeText(selected.value);
  28. toast('复制成功');
  29. };
  30. var CONTAINER = "#wrap_immediate > row > div.col-5.col-sm-5.col-md-5.col-lg-5.col-xl-5";
  31. // wait container appear and add btn
  32. var interval = setInterval(function () {
  33. var wrap = document.querySelector(CONTAINER);
  34. if (wrap) {
  35. wrap.appendChild(btn);
  36. clearInterval(interval);
  37. }
  38.  
  39.  
  40. }, 100);
  41.  
  42. function toast(msg) {
  43. var toast = document.createElement('div');
  44. toast.className = 'toast';
  45. toast.innerHTML = msg;
  46. toast.style.position = 'fixed';
  47. toast.style.bottom = '10px';
  48. toast.style.right = '10px';
  49. toast.style.zIndex = '9999';
  50. toast.style.backgroundColor = '#fff';
  51. toast.style.color = '#000';
  52. toast.style.padding = '10px';
  53. toast.style.borderRadius = '5px';
  54. toast.style.boxShadow = '0 0 5px #000';
  55. toast.style.fontSize = '16px';
  56. toast.style.fontWeight = 'bold';
  57. toast.style.opacity = '0';
  58. toast.style.transition = 'opacity 0.5s';
  59. document.body.appendChild(toast);
  60. setTimeout(function () {
  61. toast.style.opacity = '1';
  62. }, 100);
  63. setTimeout(function () {
  64. toast.style.opacity = '0';
  65. }, 2000);
  66. setTimeout(function () {
  67. toast.remove();
  68. }, 3000);
  69. }
  70. })();

QingJ © 2025

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