flomo清空笔记助手

帮你一键清空flomo笔记

Versione datata 09/10/2024. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         flomo清空笔记助手
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  帮你一键清空flomo笔记
// @author       xbp
// @match        https://v.flomoapp.com/mine
// @icon         https://v.flomoapp.com/favicon.ico
// @grant        GM_addStyle
// @grant        GM_getResourceText
// @resource     css https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css
// ==/UserScript==

(function() {
    'use strict';

    // 确保页面加载完成后再注入样式
    window.addEventListener('load', function() {
        // 添加Font Awesome的样式
        GM_addStyle(GM_getResourceText('css'));
    });

    // 创建按钮
    const button = document.createElement('button');
    button.innerHTML = '<i class="fas fa-trash-alt"></i> 清空笔记';
    button.style.position = 'fixed';
    button.style.bottom = '10px';
    button.style.left = '10px';
    button.style.zIndex = '9999';
    button.style.cursor = 'pointer';
    button.style.border = 'none';
    button.style.backgroundColor = 'transparent';
    button.style.padding = '10px';
    button.style.fontSize = '16px';
    button.style.color = 'red';
    button.title = '清空笔记';

    // 点击按钮执行操作
    button.onclick = function() {
        if (confirm('确定要清空笔记吗?')) {
            scrollAndCheck();
        }
    };

    // 将按钮添加到页面
    document.body.appendChild(button);

    // 你的原有脚本逻辑
    const scrollToBottom = (c) => {
        const element = document.querySelector(c);
        if (element) {
            element.scrollTop = element.scrollHeight;
        }
    };

    const isScrolledToBottom = () => {
        const element = document.querySelector('.end');
        return element ? element.getBoundingClientRect().bottom <= window.innerHeight : false;
    };

    function scrollAndCheck() {
        scrollToBottom('.memos');

        if (!isScrolledToBottom()) {
            console.log('No element with class "end" was found, continue scrolling...');
            setTimeout(scrollAndCheck, 1000); // 每秒检查一次
        } else {
            console.log('页面已下滑到最底部!');
            var elements = document.querySelectorAll('.item.danger');

            for (var i = 0; i < elements.length; i++) {
                if (elements[i].textContent.includes('删除')) {
                    elements[i].click();
                }
            }
        }
    }
})();