Poe2MD

Export Poe conversations to local Markdown files

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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"));
});