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.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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();