Poe2MD

Export Poe conversations to local Markdown files

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name Poe2MD
// @name:zh-CN Poe对话导出
// @namespace http://tampermonkey.net/
// @version 1.0.1
// @description Export Poe conversations to local Markdown files
// @description:zh-cn 将Poe对话导出到本地Markdown文件
// @author Trancesnow
// @match https://poe.com/chat/*
// @grant GM_registerMenuCommand
// @require https://unpkg.com/html-to-md/dist/index.js
// @license GPL-3.0-only
// ==/UserScript==

GM_registerMenuCommand("Poe2MD", () => {
  function saveStringAsFile(content) {
    const date = new Date();
    const filename = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}_${String(date.getHours()).padStart(2, "0")}-${String(date.getMinutes()).padStart(2, "0")}-${String(date.getSeconds()).padStart(2, "0")}.md`;

    const blob = new Blob([content], { "type": "text/markdown" });

    const link = document.createElement("a");
    link.href = URL.createObjectURL(blob);
    link.download = filename;

    link.click();

    URL.revokeObjectURL(link.href);
  }

  function getMarkdownMessageArray() {
    return Array.from(document
      .querySelectorAll("[class*='Prose_prose']"))
      .map(message => html2md(message.innerHTML));
  }

  saveStringAsFile(getMarkdownMessageArray().join("\n\n---\n\n"));
});