人教电子教材显示书名

显示书名

// ==UserScript==
// @name         人教电子教材显示书名
// @namespace    http://tampermonkey.net/
// @version      2024-04-20.1
// @description  显示书名
// @author       AN drew
// @match        https://jc.pep.com.cn/*
// @require      https://lib.baomitu.com/jquery/3.5.0/jquery.min.js
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    GM_addStyle(`
    .page_pc_btm_book_body{height:auto!important}
    .page_pc_btm_book_body .name{padding-left: 8px; margin:2px 14px; font-family:隶书; font-size:22px;}
    .page_pc_btm_book_body .read{margin:5px 0px 20px 20px!important}
    .textbook .item{height:auto!important}
    .textbook .item .name{padding-left: 8px; margin:2px 14px; font-family:隶书; font-size:22px;}
    .textbook .item .read{margin-top:5px!important}
    `);

    let t=setInterval(function(){
        if($('.page_pc_btm_book_body').length>0)
        {
            $('.page_pc_btm_book_body').each(function(){
                if($(this).find('.name').length>0)
                {
                    let old_title=$(this).find('.name').text();
                    let new_title=$(this).find('.imga').attr('title');
                    if(old_title != new_title)
                    {
                        $(this).find('.name').text(new_title);
                    }
                }
                else
                {
                    if($(this).find('.imga').length>0)
                    {
                        let title=$(this).find('.imga').attr('title');
                        $(this).find('.imga').after('<div class="name">'+title+'</div>');
                    }
                }
            });
        }
        if($('.textbook .item').length>0)
        {
            $('.textbook .item').each(function(){
                if($(this).find('.name').length>0)
                {
                    let old_title=$(this).find('.name').text();
                    let new_title=$(this).find('.cover').attr('alt');
                    if(old_title != new_title)
                    {
                        $(this).find('.name').text(new_title);
                    }
                }
                else
                {
                    if($(this).find('.cover').length>0)
                    {
                        let title=$(this).find('.cover').attr('title');
                        $(this).find('.cover').after('<div class="name">'+title+'</div>');
                    }
                }
            });
        }
    },1000);

})();