墨君阁

The script is for personal study and research only and is used at your own risk.

  1. // ==UserScript==
  2. // @name 墨君阁
  3. // @version M-1
  4. // @require https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js
  5. // @description The script is for personal study and research only and is used at your own risk.
  6. // @author 墨君阁
  7. // @match https://www.gaoding.com/editor/design?*
  8. // @match https://www.focodesign.com/editor/design?*
  9. // @match https://www.focodesign.com/editor/odyssey?template_id=*
  10. // @license Creative Commons (CC)
  11.  
  12. // @namespace https://gf.qytechs.cn/en/users/1324676-jack-han
  13. // ==/UserScript==
  14. (function() {
  15. 'use strict';
  16. const mobileUserAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1';
  17. Object.defineProperty(navigator, 'userAgent', {
  18. get: function() {
  19. return mobileUserAgent;
  20. },
  21. configurable: true
  22. });
  23. const originalCreateObjectURL = URL.createObjectURL;
  24. URL.createObjectURL = function() {
  25. console.error('nowBB');
  26. return null;
  27. };
  28.  
  29. function downloadImg() {
  30. let imgDom = document.querySelector('.infinite-canvas')
  31. if (!imgDom) {
  32. imgDom = document.querySelector('.editor-canvas')
  33. }if (imgDom) {
  34. var root = document.documentElement
  35. root.style.overflow = 'auto'
  36. const canvas = document.createElement('canvas')
  37. const width = parseInt(window.getComputedStyle(imgDom).width)
  38. const height = parseInt(window.getComputedStyle(imgDom).height)
  39. let scale = 1
  40. canvas.width = width * scale
  41. canvas.height = height * scale
  42. canvas.style.width = width + 'px'
  43. canvas.style.height = height + 'px'
  44. Array.from(document.querySelectorAll('.editor-layout-current div'))
  45. .filter((el) => el.classList.length===0 && el.childNodes.length===0)
  46. .forEach((el) => {
  47. el.setAttribute('data-html2canvas-ignore', '')
  48. })
  49. html2canvas(imgDom, {
  50. canvas: canvas,
  51. scale: scale,
  52. useCORS: true ,
  53. }).then((canvas) => {
  54. let dataURL = canvas.toDataURL('image/png')
  55. const el = document.createElement('a')
  56. el.download = 'PIC.png'
  57. el.href = dataURL
  58. document.body.append(el)
  59. el.click()
  60. el.remove()
  61. })
  62. }}function addTool() {
  63. const button = document.createElement('button')
  64. button.style.position = 'absolute'
  65. button.style.zIndex = '999'
  66. button.style.top = '28px'
  67. button.style.left = '800px'
  68. button.style.width = '100px'
  69. button.style.height = '32px'
  70. button.style.fontSize = '16px'
  71. button.style.background = '#ADD8E6'
  72. button.innerText = '下载 '
  73. document.body.append(button)
  74. button.onclick = downloadImg
  75. }addTool()
  76. })();

QingJ © 2025

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