FFN Paragraph Fixer

Splits up paragraphs longer than the configured number of sentences into multiple paragraphs. YMMV

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        FFN Paragraph Fixer
// @description Splits up paragraphs longer than the configured number of sentences into multiple paragraphs. YMMV
// @version     1.1.0
// @icon        https://www.fanfiction.net/static/images/favicon_2010_iphone.png
//
// @match       https://www.fanfiction.net/s/*
//
// @require     https://openuserjs.org/src/libs/sizzle/GM_config.js
//
// @grant       GM.registerMenuCommand
// @grant       GM.getValue
// @grant       GM.setValue
// @namespace https://greasyfork.org/users/814363
// ==/UserScript==

GM_config.init({
  id: "ConfigBox",
  title: "FFN Paragraph Fixer Configuration",
  fields: {
    paraLength: {
      label: "Maximum Paragraph Length",
      type: "int",
      min: 1,
      default: 3
    }
  },
  css: "#ConfigBox { color: #fff; background-color: #222; }"
})

let doReplacement = () => [...document.getElementById("storytext").getElementsByTagName("p")]
	.forEach(p => p.innerHTML = p.innerHTML.replace(new RegExp(`(\\s*[<>/A-Za-z0-9,;'"\\s-]+[.?!]+"?){${GM_config.get("paraLength")}}`, "g"), "$&</p><p>"))

GM.registerMenuCommand("Open FFN Paragraph Fixer Config", () => GM_config.open())
document.addEventListener("keydown", e => { if (e.ctrlKey && e.altKey && e.key.toString() === "/") { GM_config.open() } })

GM.registerMenuCommand("Break Up Long Paragraphs", doReplacement);
document.addEventListener("keydown", e => { if (e.ctrlKey && !e.altKey && e.key.toString() === "/") { doReplacement() } })