Royal Road - clean up text for Text to Speach (TTS)

Improve use of TTS (Text to Speach) app, like ReadAloud, on RR. This script removes artfacts and stops the TTS app to ommit some words. The app also removes the footer on chapter pages because it is annoying to hear in the TTS app. The app also removes <strong>repeated special characters</strong> like stacks of 20 '=' because it is very annoying to hear in the TTS app.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Royal Road - clean up text for Text to Speach (TTS)
// @namespace    http://tampermonkey.net/
// @version      1.01
// @description  Improve use of TTS (Text to Speach) app, like ReadAloud, on RR. This script removes artfacts and stops the TTS app to ommit some words. The app also removes the footer on chapter pages because it is annoying to hear in the TTS app. The app also removes <strong>repeated special characters</strong> like stacks of 20 '=' because it is very annoying to hear in the TTS app. 
// @author       djjudjju25
// @match        https://www.royalroad.com/fiction/*/*/chapter/*/*
// @license MIT
// @grant        none
// ==/UserScript==

function clean() {
    'use strict';

    removeLessGreaterThan(document.getElementsByClassName('chapter-content')[0]);

    function removeLessGreaterThan(chapter) {
        if (chapter) {
            for (let x of chapter.children) {
                x.innerHTML = x.getInnerHTML()
                    .replace(/&lt;/g, '[')
                    .replace(/&gt;/g, ']')
                    .replace(/(\b)(Iv)(\b)/g, '$1Yve$3')
                    .replace(/(\b)(Sch)/g, '$1Sh')
                    .replace(/--+/g, "‒‒")
                    .replace(/==+/g, '==')
                    .replace(/\/\/+/g, '/')
                  ;
            }
        }
    }
}

function removeFooter() {
    document.getElementsByClassName('page-prefooter')[0]?.remove();
    document.getElementsByClassName('footer')[0]?.remove();
}

removeFooter();
clean();