linovelib restore volumn

Restore volumn deleted by the detector

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         linovelib restore volumn
// @namespace    http://tampermonkey.net/
// @license MIT
// @version      0.4.1
// @description  Restore volumn deleted by the detector
// @author       gwsl
// @match        https://*.linovelib.com/novel/*/catalog
// @match        https://*.bilinovel.com/novel/*/catalog
// @match        https://*.linovelib.com/novel/*/*.html
// @match        https://*.bilinovel.com/novel/*/*.html
// @match        https://*.linovelib.com/download/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=linovelib.com
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function () {
    'use strict';
    if (location.href.endsWith('catalog')) {
        restoreVolumns();
    }

    if (/novel\/\d+\/\d+(_\d+)?.html$/.test(location.href)) {
        restoreChapterContent();
    }
})();

function restoreChapterContent() {
    var content = document.querySelector('#acontent');
    if (content == null) return;

    console.log('observe content display.')
    var config = { attributes: true };
    var observer = new MutationObserver((mutationsList) => {
        for (let record of mutationsList) {
            if (record.type == 'attributes') {
                /** @type {HTMLElement} */
                var target = record.target;
                if (target.style.getPropertyValue('display') == 'none') {
                    target.style.setProperty('display', 'block');
                    target.previousElementSibling?.remove();
                    target.classList.remove('adv-box');
                    console.log('restore chapter content.');
                }
            }
        }
    });
    observer.observe(content, config);
}

function restoreVolumns() {
    var ele = document.querySelector('#volume-list,#volumes');
    if (ele == null) return;

    console.log('observe volumns display.')
    var config = { attributes: true };
    var observer = new MutationObserver((mutationsList) => {
        for (let record of mutationsList) {
            if (record.type == 'attributes') {
                /** @type {HTMLElement} */
                var target = record.target;
                if (target.style.getPropertyValue('display') == 'none') {
                    target.style.setProperty('display', 'block');
                    target.previousElementSibling?.remove();
                    console.log('restore volumns.')
                }
            }
        }
    });
    observer.observe(ele, config);
}