粉笔真题排版优化,答案自动展开

移除左侧空白,右侧真题答案居中,答案自动展开,精简内容

目前为 2023-05-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         粉笔真题排版优化,答案自动展开
// @namespace    https://greasyfork.org/zh-CN/scripts/465487
// @version      1.0
// @description  移除左侧空白,右侧真题答案居中,答案自动展开,精简内容
// @author       yingming006
// @match        https://spa.fenbi.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=fenbi.com
// @grant        none
// @license      GPL-3.0 License
// ==/UserScript==

(function() {
    'use strict';

    setTimeout(delLeft, 300);
    setTimeout(zhentibody, 300);
    setTimeout(btn, 300);
    setTimeout(question, 300);

    function delLeft() {
        // 删除左侧空白
        document.querySelector('.zhenti-body-left.zhenti-body-part.bg-color-gray-light5').remove();
        document.querySelector('fb-expand').remove();
    }

    function zhentibody() {
        // 题目解析居中
        const zhentibody = document.querySelector('.zhenti-body');
        zhentibody.style.display = '';
        zhentibody.style.width = '1180px';
        zhentibody.style.margin = 'auto';

        document.querySelector('.questions-container').style.paddingLeft = '0';
        document.querySelector('.question-content').style.width = '1180px';

        const questionbody = document.querySelector('.question-body');
        questionbody.style.height = 'auto';
    }

    function btn() {
        // 下一题 刷新
        document.querySelector('.bg.last-bg').onclick = function(){
            setTimeout(zhentibody, 300);
            setTimeout(question, 300)
        }

        // 上一题 刷新
        document.querySelector('.bg.next-bg').onclick = function(){
            setTimeout(zhentibody, 300);
            setTimeout(question, 300)
        }
    }

    function question() {
        // 展开题目解析
        document.querySelector('.reference-detail.bg-color-gray-light3').classList.add('reference-detail-show');
        document.querySelector('.reference-btn').remove();

        // 删除会员
        document.querySelector('.member-title').remove();
        document.querySelector('.member-content-sections').remove();
        document.querySelector('.member-open-big').remove();

        // 自动展开答案
        document.querySelector('.accessory-container.member.last-one').classList.remove('last-one');

        // 删除答案样式
        document.querySelector('.member-section.brightness-60.ng-star-inserted').classList.remove('member-section');

        // 删除笔记
        let nodes = document.querySelectorAll('.accessory-container');
        nodes[nodes.length-1].remove();
    }
})();