Jinxin Util Button

界面按钮工具类

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/460642/1330385/Jinxin%20Util%20Button.js

  1. // ==UserScript==
  2. // @name Jinxin Util Button
  3. // @namespace https://gitee.com/jinxin11112/tampermonkey
  4. // @version 0.1.2
  5. // @description 界面按钮工具类
  6. // @author jinxin
  7. // @icon https://picss.sunbangyan.cn/2024/02/11/a19cea286d366718e1358c1060c7c04e.jpeg
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. let fontAwesome = document.createElement('link');
  13. fontAwesome.type = 'text/css';
  14. fontAwesome.rel = 'stylesheet';
  15. fontAwesome.href = 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css';
  16. document.head.appendChild(fontAwesome);
  17.  
  18. function addDownloadButton(buttonFun) {
  19. let button = document.createElement('i');
  20. let icon = document.createElement('i');
  21. icon.className = 'fa-solid fa-download';
  22. button.appendChild(icon)
  23. button.title = '下载';
  24. // noinspection JSValidateTypes
  25. button.style = `
  26. position: fixed;
  27. bottom: 20px;
  28. left: 20px;
  29. display: flex;
  30. flex-direction: column;
  31. align-items: end;
  32. z-index: 999;
  33. cursor:pointer;
  34. `;
  35. button.addEventListener('click', buttonFun);
  36. (document.body || document.documentElement).appendChild(button);
  37. }