粉笔网刷题宝

粉笔网优化布局,清屏快速生成pdf

目前为 2023-11-14 提交的版本。查看 最新版本

// ==UserScript==
// @name         粉笔网刷题宝
// @namespace    http://tampermonkey.net/
// @version      0.0.34
// @author       binyellow
// @icon         https://nodestatic.fbstatic.cn/weblts_spa_online/page/assets/fenbi32.ico
// @defaulticon  粉笔网优化布局,清屏快速生成pdf
// @match        https://www.fenbi.com/*
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @description 粉笔网优化布局,清屏快速生成pdf
// ==/UserScript==

(function ($) {
  'use strict';

  let did = {};
  const cbs = [];
  function shenlun() {
    const leftSubject = $(".zhenti-body-left.zhenti-body-part.bg-color-gray-light5");
    leftSubject.find(".materials-container").css({ width: "100%", padding: 12 });
    leftSubject.find(".material-content.ng-tns-c41-0").css({ width: "100%" });
    leftSubject.find(".material-content.ng-tns-c41-0").find("#material").css({ width: "100%" });
    const rightAnser = $(".zhenti-body-right.zhenti-body-part");
    rightAnser.css({ flex: "none" });
    rightAnser.find(".questions-container").css({ "padding-left": "12px" });
  }
  cbs.push((node) => {
    var _a;
    const xingCeTiMu = $(node).find("main.exam-content");
    if ((xingCeTiMu == null ? void 0 : xingCeTiMu.length) && !(did == null ? void 0 : did.xingce)) {
      did.xingce = true;
      const css = { margin: 0 };
      $("main.exam-content").css(css);
      $(".simple-nav-header.bg-color-gray-bold").hide();
      const optionsCls = ".options.choice-options.font-color-gray-mid.ng-star-inserted";
      $(optionsCls).css({ display: "flex" });
      $(".nav-coll-divider").hide();
      $(".solu-list.border-gray-light4").css({ "margin-top": 0 });
      $(".solu-answer-text.clear-float.ng-star-inserted").hide();
      $(".bg-color-gray-light2.border-gray-light3.font-color-gray-mid.expend-btn").hide();
      $(".solu-list-item.video-item").css({ "margin-bottom": 0 });
      $(".solu-list-item.video-item fb-ng-solution-detail-item").hide();
      $("<style>.fb-collpase-bottom { width: calc(100% - 1024px); right: 0; }</style>").appendTo("head");
      $(".fb-collpase-bottom.bg-color-gray-mid").css({ margin: 0, width: "100%" });
      $(".fixedActions.bg-color-gray-bold").css({ right: 0 });
      did.xingce = false;
      shenlun();
    }
    if (((_a = $(".fb-question-material")) == null ? void 0 : _a.length) && !did.zhaiping) {
      did.zhaiping = true;
      $(".fb-question-material").css({ margin: 12 });
      $(".material-content").css({ padding: 0 });
      $(".ques-options-dry").css({ padding: 0 });
      $(".options.font-color-gray-mid").css({ display: "flex" });
    }
    const collections = $(".solution-item.bg-color-gray-bold");
    if ((collections == null ? void 0 : collections.length) && !did.collectionDid) {
      collections.each(function() {
        const solution = $(this).find(".solu-list.border-gray-light4");
        $(solution).css({ padding: 8 });
        $(solution).find("fb-ng-solution-detail-answer").hide();
      });
      did.collectionDid = true;
    }
    const collectionBtn = $(
      ".solution-item.bg-color-gray-bold>app-fb-solution>fb-ng-solution > div[_ngcontent-fenbi-web-exams-c75] > div[_ngcontent-fenbi-web-exams-c75]"
    );
    if ((collectionBtn == null ? void 0 : collectionBtn.length) && !did.collectionBtnDid) {
      collectionBtn.each(function() {
        $(this).css({ position: "absolute", right: 0 });
        console.log(this);
      });
      did.collectionBtnDid = true;
    }
  });
  cbs.push(() => {
    const caogao = $(".draft-icon");
    if (caogao == null ? void 0 : caogao.length) {
      $(caogao).on("click", function() {
        console.log("draft-icon 被点击");
        $(document).on("keydown", function(event) {
          if (event.key === "Escape" || event.keyCode === 27) {
            $(".tool-item.exit").trigger("click");
            $(document).off("keydown");
          }
        });
      });
    }
  });
  cbs.push(() => {
    const mokaoLeft = $(".exam-post-nav");
    const fixedRightBtn = $(".fixedActions.bg-color-gray-bold");
    if (!did.addClearBtn && (fixedRightBtn == null ? void 0 : fixedRightBtn.length)) {
      did.addClearBtn = true;
      var newButton = $("<button>清屏</button>");
      var newInput = $('<input type="number" value="180">');
      $(".fixedActions.bg-color-gray-bold").children().first().before(newButton).before(newInput);
      newButton.on("click", function() {
        const scrollDom = $("#fenbi-web-exams");
        scrollDom.scrollTop(scrollDom[0].scrollHeight);
        var examContent = $("main.exam-content");
        var inputValue = newInput.val();
        $("body").empty();
        $("body").append(examContent);
        $("body").append(`<style>
                .fixedActions.bg-color-gray-bold,.fb-collpase-bottom, app-side-tool,.fb-question > div:last-child[_ngcontent-fenbi-web-exams-c68],div[_ngcontent-fenbi-web-exams-c69] > div[_ngcontent-fenbi-web-exams-c69],.content.font-color-gray-mid>p.ques-type {
                display: none;
                }

                .fb-question-options.fenbi-ng-utils > div[_ngcontent-fenbi-web-exams-c40] {
padding: 16px 0 0 0;
margin-bottom: ${inputValue}px;
                }

                .options.font-color-gray-mid {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
                }

                .options.font-color-gray-mid > li {
margin: 0 !important;
                }
                [_nghost-fenbi-web-exams-c40] p {
                font-weight: normal;
                }

                main.exam-content {
margin-right: 35px !important;
                }
                .material-nav.bg-color-gray-light {
                display: none;
                }
                </style>`);
        $(".nav-coll-divider").hide();
      });
    }
    if ((mokaoLeft == null ? void 0 : mokaoLeft.length) && !did.mokao) {
      did.mokao = true;
      $(mokaoLeft).css({ left: 0, top: 0 });
      const detailContent = $(".solution-detail.clear-float");
      $(detailContent).css({ width: "100%" });
      const optionsUl = $(detailContent).find(".options.ng-star-inserted");
      $(optionsUl).css({ display: "flex", "justify-content": "space-between", "flex-wrap": "wrap" });
      optionsUl.children().css("margin", "0");
      $(detailContent).find(".exam-main-content.ng-tns-c3-0.ng-star-inserted").css({ width: "calc(100% - 302px)" });
      $(".practice-header").hide();
      $(detailContent).find(".solu-detail.ng-star-inserted").css({ margin: 0, padding: 0 });
      $(detailContent).find(".nav-coll-divider.solu-divider").css({ margin: "6px 0" });
      $(detailContent).find(".question-content > p:nth-child(2) > img").each(function() {
        var img = $(this);
        var width = img.width() || 0;
        var height = img.height() || 0;
        var newWidth = width * 0.6;
        var newHeight = height * 0.6;
        img.width(newWidth);
        img.height(newHeight);
      });
    }
  });
  const initCbs = [];
  const dealWidth = () => {
    const cssRules = `
@media (max-width: 1000px) {
.exam-content {
  width: calc(100% - 45px) !important;
}
#app-practice {
  min-width: 100% !important;
}
.tools-container {
left: 0;
}
.fb-collpase-bottom {
left: 0;
width: 100% !important;
}
}
`;
    const styleTag = document.createElement("style");
    styleTag.innerHTML = cssRules;
    document.head.appendChild(styleTag);
  };
  initCbs.push(() => dealWidth());
  initCbs.push(() => {
  });
  initCbs.forEach((cb) => cb());
  function observeDom(container) {
    function handleMutation(mutation) {
      if (mutation.type === "childList") {
        mutation.addedNodes.forEach((node) => {
          cbs.forEach((cb) => cb(node));
        });
      }
    }
    const observer = new MutationObserver((mutations) => {
      mutations.forEach(handleMutation);
    });
    observer.observe(container, { childList: true, subtree: true });
  }
  observeDom(document.body);

})($);

QingJ © 2025

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