copy icloud reminder content

copy icloud reminder content in icloud website

  1. // ==UserScript==
  2. // @name copy icloud reminder content
  3. // @author ziqiya
  4. // @version 1.0.0
  5. // @namespace https://github.com/ziqiya/copyReminder
  6. // @description copy icloud reminder content in icloud website
  7. // @match *://*.icloud.com/*
  8. // @match *://*.icloud.com.cn/*
  9. // @grant GM_setClipboard
  10. // @license Apache Licence 2.0
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. // 创建按钮
  17. const button = document.createElement('button');
  18. button.innerText = 'copy content';
  19. button.style.position = 'fixed';
  20. button.style.top = '10px';
  21. button.style.right = '10px';
  22. button.style.padding = '10px';
  23. button.style.fontSize = '14px';
  24. button.style.backgroundColor = '#007BFF';
  25. button.style.color = 'white';
  26. button.style.border = 'none';
  27. button.style.borderRadius = '5px';
  28. button.style.cursor = 'pointer';
  29. button.style.zIndex = '9999'; // 确保按钮在页面最上层
  30.  
  31. // 将按钮添加到页面
  32. document.body.appendChild(button);
  33.  
  34. // 设置 MutationObserver 来监听 DOM 变化
  35. const observer = new MutationObserver(() => {
  36. // 当 DOM 内容发生变化时,确保按钮依然可用
  37. const elements = document.querySelectorAll('.tt-input-field');
  38. if (elements.length > 0) {
  39. button.style.display = 'block';
  40. } else {
  41. button.style.display = 'none';
  42. }
  43. });
  44.  
  45. // 配置 MutationObserver 监听 DOM 内容的变化
  46. observer.observe(document.body, {
  47. childList: true, // 监听子节点的变化
  48. subtree: true // 监听整个文档树的变化
  49. });
  50.  
  51. // 点击按钮时的处理逻辑
  52. button.addEventListener('click', () => {
  53. const elements = document.querySelectorAll('.tt-input-field');
  54. let content = '';
  55.  
  56. // 拼接所有内容,每个元素后面加换行符
  57. elements.forEach(element => {
  58. content += element.innerText.trim() + '\n';
  59. });
  60.  
  61. if (content) {
  62. // 复制到剪贴板
  63. GM_setClipboard(content);
  64.  
  65. // 提示用户复制成功
  66. alert('Copied successfully!');
  67. } else {
  68. alert('No content found');
  69. }
  70. });
  71. })();