flomo清空笔记助手

帮你一键清空flomo笔记

当前为 2024-10-09 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name flomo清空笔记助手
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description 帮你一键清空flomo笔记
  6. // @author xbp
  7. // @match https://v.flomoapp.com/mine
  8. // @icon https://v.flomoapp.com/favicon.ico
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // 创建按钮
  15. const button = document.createElement('button');
  16. button.textContent = '清空笔记';
  17. button.style.position = 'fixed';
  18. button.style.bottom = '10px';
  19. button.style.left = '10px';
  20. button.style.zIndex = '9999';
  21. button.style.cursor = 'pointer';
  22.  
  23. // 点击按钮执行操作
  24. button.onclick = function() {
  25. if (confirm('确定要清空笔记吗?')) {
  26. scrollAndCheck();
  27. }
  28. };
  29.  
  30. // 将按钮添加到页面
  31. document.body.appendChild(button);
  32.  
  33. // 你的原有脚本逻辑
  34. const scrollToBottom = (c) => {
  35. const element = document.querySelector(c);
  36. if (element) {
  37. element.scrollTop = element.scrollHeight;
  38. }
  39. };
  40.  
  41. const isScrolledToBottom = () => {
  42. const element = document.querySelector('.end');
  43. return element ? element.getBoundingClientRect().bottom <= window.innerHeight : false;
  44. };
  45.  
  46. function scrollAndCheck() {
  47. scrollToBottom('.memos');
  48.  
  49. if (!isScrolledToBottom()) {
  50. console.log('No element with class "end" was found, continue scrolling...');
  51. setTimeout(scrollAndCheck, 1000); // 每秒检查一次
  52. } else {
  53. console.log('页面已下滑到最底部!');
  54. var elements = document.querySelectorAll('.item.danger');
  55.  
  56. for (var i = 0; i < elements.length; i++) {
  57. if (elements[i].textContent.includes('删除')) {
  58. elements[i].click();
  59. }
  60. }
  61. }
  62. }
  63. })();