联合阅读辅助插件

优化联合阅读一些程序方面体验

目前為 2021-01-07 提交的版本,檢視 最新版本

// ==UserScript==
// @name         联合阅读辅助插件
// @namespace    http://*.xrzww.com/
// @version      1.2
// @license      Anti 996 License
// @description  优化联合阅读一些程序方面体验
// @author       qidian55
// @match        http*://*.xrzww.com/*
// @grant        GM_notification
// @require      https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// ==/UserScript==
(function() {
    //添加签到功能
    var right = $('#app .nan_page .main .right')[0];
    if (right === undefined) return;
    var signin_button = $(`
<uni-view style=" margin-left:25px;
 width:74px;
 height:30px;
 border-radius:18px" class="top_right">
    <uni-view style=" display:-webkit-box;
     display:-webkit-flex;
     display:flex;
     font-size:14px;
     height:25px;
     -webkit-box-pack:center;
     -webkit-justify-content:center;
     justify-content:center;
     -webkit-box-align:center;
     -webkit-align-items:center;
     align-items:center;
     border:1px solid #fff;
     background:-webkit-linear-gradient(179deg,#ffedd6,#ffdcb4);
     background:linear-gradient(271deg,#ffedd6,#ffdcb4);
     box-shadow:0 3px 6px #8d0006;
     color:#8d0006;
     border-radius:17px;
    box-sizing: border-box;" class="btn all">
        <uni-text><span>签到▶</span></uni-text>
    </uni-view>
</uni-view>`)[0];
    right.appendChild(signin_button);
    var signin = function() {
        $.ajax({
            url: "https://pre-api.xrzww.com/api/userSignIn",
            headers: {
                "Authorization": "Bearer " + localStorage['token']
            },
            success: function(result) {
                GM_notification('签到成功!\n+' + result.data.gold2 + '书币\n本周连续签到' + result.data.week_sign_count + '天', '联合阅读辅助插件', 'https://oss.xrzww.com/mini/mine_qian.png');
                $(signin_button).find('uni-text').children('span').html('已签');
                $(signin_button).children('uni-view')[0].style.cursor = '';
                $(signin_button).find('.btn')[0].onclick = undefined;
            }
        });
    }
    $.ajax({
        url: "https://pre-api.xrzww.com/api/getUserInfo",
        headers: {
            "Authorization": "Bearer " + localStorage['token']
        },
        success: function(result) {
            if (result.data.signstatus) $(signin_button).find('uni-text').children('span').html('已签');
            else {
                $(signin_button).children('uni-view')[0].style.cursor = 'pointer';
                $(signin_button).find('.btn')[0].onclick = signin;
            }
        }
    });
})();
(function() {
    //添加朗读功能
    var novel_left = $('.novel_left')[0];
    if (novel_left === undefined) return;
    var speak_service = $(`<div data-v-803acc24="" style="background: rgb(102, 204, 255) none repeat scroll 0% 0%;" class="set_bar">
    <div data-v-803acc24="" class="widthcaozuo" style="background: rgb(102, 204, 255) none repeat scroll 0% 0%;visibility: hidden;">
        <div data-v-803acc24="" style="background: rgb(102, 204, 255) none repeat scroll 0% 0%;position: inherit;left: 81px;" class="set_bar">
            <div data-v-803acc24="" class="caozuo">
                <div data-v-803acc24="">
                    <i data-v-803acc24="" class="el-icon-video-pause"></i>
                </div>
                <span data-v-803acc24="">暂停</span>
            </div>
        </div>
        <div data-v-803acc24="" style="background: rgb(102, 204, 255) none repeat scroll 0% 0%;position: inherit;left: 152px;cursor: auto;padding: 0 0;" class="set_bar">
            <div data-v-803acc24="" class="caozuo">
                <div style="height: 24.25px;flex-direction: column;justify-content: center;display: flex;cursor: pointer;">
                    <i data-v-803acc24="" class="el-icon-caret-right"></i>
                </div>
                <span style="margin-top: 0px;">语速:1.0</span>
                <div style="height: 24.25px;flex-direction: column;justify-content: center;display: flex;cursor: pointer;">
                    <i data-v-803acc24="" class="el-icon-caret-left"></i>
                </div>
            </div>
        </div>
        <div data-v-803acc24="" style="background: rgb(102, 204, 255) none repeat scroll 0% 0%;position: inherit;left: 223px;cursor: auto;padding: 0 0;" class="set_bar">
            <div data-v-803acc24="" class="caozuo">
                <div style="height: 24.25px;flex-direction: column;justify-content: center;display: flex;cursor: pointer;">
                    <i data-v-803acc24="" class="el-icon-caret-top"></i>
                </div>
                <span style="margin-top: 0px;">音量:1.0</span>
                <div style="height: 24.25px;flex-direction: column;justify-content: center;display: flex;cursor: pointer;">
                    <i data-v-803acc24="" class="el-icon-caret-bottom"></i>
                </div>
            </div>
        </div>
    </div>
    <div data-v-803acc24="" class="caozuo">
        <div data-v-803acc24="">
            <i data-v-803acc24="" class="el-icon-service"></i>
        </div>
        <span data-v-803acc24="">朗读</span>
    </div>
</div>`)[0];
    novel_left.appendChild(speak_service);
    var utterThis = new SpeechSynthesisUtterance();
    speak_service.utterThis = utterThis;
    var read_next_paragraph = function(e) {
        speak_service.current_paragraph[0].style.background = '';
        speak_service.current_paragraph = speak_service.current_paragraph.next();
        if (speak_service.current_paragraph.attr('class') === 'others') return;
        speak_service.utterThis.text = speak_service.current_paragraph.text().trim();
        window.speechSynthesis.speak(speak_service.utterThis);
    }
    var start_speak_service = function() {
        if (!$('.novel_dl').length) return;
        speak_service.current_paragraph = $($('.novel_dl')[0]);
        speak_service.utterThis.text = speak_service.current_paragraph.text().trim()
        speak_service.utterThis.onstart = function(e) {
            speak_service.current_paragraph[0].style.background = 'rgba(102,204,255,0.3)';
            speak_service.current_paragraph[0].scrollIntoView({
                behavior: 'smooth'
            });
        };
        speak_service.utterThis.onend = read_next_paragraph;
        window.speechSynthesis.speak(utterThis);
        speak_service.firstElementChild.style.visibility = '';
        $(this).find('i').attr('class', 'el-icon-loading');
        $(this).find('span').text('朗读中');
        this.onclick = stop_speak_service;
    }
    var stop_speak_service = function() {
        speak_service.current_paragraph[0].style.background = '';
        speak_service.utterThis.onend = undefined;
        window.speechSynthesis.cancel();
        $(this).find('i').attr('class', 'el-icon-service');
        $(this).find('span').text('朗读');
        speak_service.firstElementChild.style.visibility = 'hidden';
        this.onclick = start_speak_service;
    }
    speak_service.lastElementChild.onclick = start_speak_service;
    var pause_speak_service = function() {
        window.speechSynthesis.pause();
        $(speak_service.lastElementChild).find('i')[0].style.animationPlayState = 'paused';
        $(speak_service.lastElementChild).find('i')[0].style.WebkitAnimationPlayState = 'paused';
        $(this).find('i').attr('class', 'el-icon-video-play');
        $(this).find('span').text('继续');
        this.onclick = resume_speak_service;
    }
    var resume_speak_service = function() {
        window.speechSynthesis.resume();
        $(speak_service.lastElementChild).find('i')[0].style.animationPlayState = 'running';
        $(speak_service.lastElementChild).find('i')[0].style.WebkitAnimationPlayState = 'running';
        $(this).find('i').attr('class', 'el-icon-video-pause');
        $(this).find('span').text('暂停');
        this.onclick = pause_speak_service;
    }
    speak_service.firstElementChild.children[0].onclick = pause_speak_service;
    $(speak_service).find('.el-icon-caret-left').parent()[0].onclick = function() {
        speak_service.utterThis.rate -= 0.5;
        $(speak_service).find('span')[1].textContent = '语速:' + speak_service.utterThis.rate.toFixed(1);
    };
    $(speak_service).find('.el-icon-caret-right').parent()[0].onclick = function() {
        speak_service.utterThis.rate += 0.5;
        $(speak_service).find('span')[1].textContent = '语速:' + speak_service.utterThis.rate.toFixed(1);
    };
    $(speak_service).find('.el-icon-caret-bottom').parent()[0].onclick = function() {
        speak_service.utterThis.volume -= 0.1;
        $(speak_service).find('span')[2].textContent = '音量:' + speak_service.utterThis.volume.toFixed(1);
    };
    $(speak_service).find('.el-icon-caret-top').parent()[0].onclick = function() {
        speak_service.utterThis.volume += 0.1;
        $(speak_service).find('span')[2].textContent = '音量:' + speak_service.utterThis.volume.toFixed(1);
    };
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址