Greasy Fork 还支持 简体中文。

清空笔记助手

在页面左下角添加一个按钮,点击后清空笔记

目前為 2024-10-09 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name 清空笔记助手
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 在页面左下角添加一个按钮,点击后清空笔记
  6. // @author 你的名字
  7. // @match https://v.flomoapp.com/mine
  8. // @grant none
  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.title = '清空笔记';
  22.  
  23. // 鼠标悬停显示文字
  24. button.onmouseover = function() {
  25. this.textContent = '清空笔记';
  26. };
  27.  
  28. // 点击按钮执行操作
  29. button.onclick = function() {
  30. if (confirm('确定要清空笔记吗?')) {
  31. scrollAndCheck();
  32. }
  33. };
  34.  
  35. // 将按钮添加到页面
  36. document.body.appendChild(button);
  37.  
  38. // 你的原有脚本逻辑
  39. const scrollToBottom = (c) => {
  40. const element = document.querySelector(c);
  41. console.log(element);
  42. element.scrollTop = element.scrollHeight;
  43. };
  44.  
  45. const isScrolledToBottom = () => {
  46. const element = document.querySelector('.end');
  47. return element ? element.getBoundingClientRect().bottom <= window.innerHeight : false;
  48. };
  49.  
  50. function scrollAndCheck() {
  51. scrollToBottom('.memos');
  52.  
  53. if (!isScrolledToBottom()) {
  54. console.log('No element with class "end" was found, continue scrolling...');
  55. setTimeout(scrollAndCheck, 1000); // 每秒检查一次
  56. } else {
  57. console.log('页面已下滑到最底部!');
  58. var elements = document.querySelectorAll('.item.danger');
  59.  
  60. for (var i = 0; i < elements.length; i++) {
  61. if (elements[i].textContent.includes('删除')) {
  62. elements[i].click();
  63. }
  64. }
  65. }
  66. }
  67. })();