Readli Cleaner

Удаляет лишнее содержимое, заменяет буквы и удаляет "Ридли" из OG Title на readli.net

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Readli Cleaner
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  Удаляет лишнее содержимое, заменяет буквы и удаляет "Ридли" из OG Title на readli.net
// @author       You
// @match        https://readli.net/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    // Функция для замены букв с учётом тегов ссылок и пустых тегов
    function replaceTextWithLinks(text) {
        // Регулярное выражение для поиска текста вне тегов и непустых тегов
        const textRegex = /(>|^)([^<]+)(?=<|$)/g;

        return text.replace(textRegex, function(match, p1, textContent) {
            // Проверяем, не является ли текст пустым
            if (textContent.trim() === "") {
                return match; // Возвращаем исходное совпадение без изменений
            }

            // Замена букв в текстовом содержимом
            let replacedText = textContent
                .replace(/c/g, 'с')
                .replace(/p/g, 'р')
                .replace(/r/g, 'г')
                .replace(/x/g, 'х')
                .replace(/o/g, 'о')
                .replace(/e/g, 'е')
                .replace(/y/g, 'у')
                .replace(/C/g, 'С')
                .replace(/M/g, 'М')
                .replace(/K/g, 'К')
                .replace(/E/g, 'Е')
                .replace(/A/g, 'А')
                .replace(/H/g, 'Н')
                .replace(/T/g, 'Т')
                .replace(/P/g, 'Р')
                .replace(/O/g, 'О')
                .replace(/X/g, 'Х')
                .replace(/nbsр/g, 'nbsp')
                .replace(/a/g, 'а');

            return `${p1}${replacedText}`;
        });
    }

    // Замена букв и символов внутри <p> с учётом ссылок
    document.querySelectorAll('p').forEach(function(paragraph) {
        paragraph.innerHTML = replaceTextWithLinks(paragraph.innerHTML);
    });

    // Удаление "Ридли" из тега <title>
    var titleElement = document.querySelector("title");
    if (titleElement) {
        titleElement.textContent = titleElement.textContent.replace("Ридли", "");
    }

    // Function to remove comments within a specific element
    function removeComments(element) {
        const commentRegex = /<!-- readli_online -->/g;
        element.innerHTML = element.innerHTML.replace(commentRegex, '');
    }

    // Target divs with the class "reading wrapper" and remove comments
    document.querySelectorAll('div.reading.wrapper').forEach(function(readingDiv) {
        removeComments(readingDiv);
    });
    // Удаление "Ридли" из тега og:title
    var ogTitleElement = document.querySelector('meta[property="og:title"]');
    if (ogTitleElement) {
        ogTitleElement.content = ogTitleElement.content.replace("Ридли", "");
    }

})();