Poe Content Summarizer

Summarize clipboard content on Poe and auto-submit with smooth delay

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Poe Content Summarizer
// @namespace    http://tampermonkey.net/
// @version      1.68
// @description  Summarize clipboard content on Poe and auto-submit with smooth delay
// @match        https://poe.com/*
// @icon         https://plus.unsplash.com/premium_photo-1673795754005-214e3e1fccba?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxmZWF0dXJlZC1waG90b3MtZmVlZHwzN3x8fGVufDB8fHx8fA%3D%3D
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    let lastKeyTime = 0;
    let consecutiveOne = 0;

    document.addEventListener('keydown', function(e) {
        if (e.key === '1') {
            let currentTime = new Date().getTime();
            if (currentTime - lastKeyTime < 500) {
                consecutiveOne++;
                if (consecutiveOne === 2) {
                    e.preventDefault();
                    summarizeClipboard();
                }
            } else {
                consecutiveOne = 1;
            }
            lastKeyTime = currentTime;
        } else {
            consecutiveOne = 0;
        }
    });

    function summarizeClipboard() {
        navigator.clipboard.readText().then(clipText => {
            let textArea = document.querySelector('textarea');
            if (textArea) {
                // 移除剪贴板内容开头和结尾的空白字符
                clipText = clipText.trim();
                textArea.value = `${clipText}\n\n##内容总结与分析提示:\n
你是一位内容总结专家,请对以下内容进行深入分析:
1.详细总结:请对内容进行全面总结,涵盖主要观点和细节。
2.提炼核心观点:从内容中提炼出5个或更多的核心观点,确保观点清晰且具有代表性。
3.相关问题:基于内容,提出一个相关的、同时期出现的问题,并进行详细回答。
4.尊重原文:确保总结和观点提炼忠实于内容原文,避免产生幻觉或误解。
请尽可能详细地回答,确保覆盖所有重要要点。##`;
                textArea.dispatchEvent(new Event('input', { bubbles: true }));

                // 添加延迟以使过程更加顺滑
                setTimeout(() => {
                    // 模拟按下回车键
                    const enterEvent = new KeyboardEvent('keydown', {
                        bubbles: true,
                        cancelable: true,
                        keyCode: 13,
                        which: 13,
                        key: 'Enter'
                    });
                    textArea.dispatchEvent(enterEvent);
                }, 300); // 300毫秒的延迟,可以根据需要调整
            }
        });
    }
})();