BIT北理工一键评教 - pj.bit.edu.cn

一键完成所有单选项并提交,可自定义评价选项;修复评教按钮不显示的问题

Pada tanggal 09 Desember 2024. Lihat %(latest_version_link).

// ==UserScript==
// @name        BIT北理工一键评教 - pj.bit.edu.cn
// @namespace   Violentmonkey Scripts
// @match       https://pj.bit.edu.cn/pjxt2.0/*
// @grant       GM_addStyle
// @version     2.1.0
// @author      xioneko
// @description 一键完成所有单选项并提交,可自定义评价选项;修复评教按钮不显示的问题
// @license     MIT
// ==/UserScript==

// 修复评教按钮显示问题
if (document.URL.endsWith('queryListStpj')) {
  GM_addStyle(`
    .visible-desktop {
      display: unset !important;
    }
  `)
}

// 仅对未评价课程的评价页生效
if (document.URL.endsWith('evaluateCourseInfo.do') &&
      document.querySelector('a[onclick^="savePjxx"]')) {
          
  document.querySelector('.create_tit')
    .insertAdjacentHTML('beforeend', `
      <div id="pj-input">
        <select id="pj-select">
          <option value="1" selected>非常符合</option>
          <option value="2">比较符合</option>
          <option value="3">一般</option>
          <option value="4">比较不符合</option>
          <option value="5">非常不符合</option>
        </select>
        <div id="pj-btn">提交</div>
      </div>
    `);

  (()=>{
    const QUESTION_NUM = 9; // 问题数量固定

    const submitBtn = document.querySelector('#pj-btn')

    submitBtn.addEventListener('click', () => {
      const selection = document.querySelector('#pj-select').value;

      [...Array(QUESTION_NUM).keys()].forEach(_ => {
        document.querySelector(`#pjnr_${_ + 1}_${selection}`).checked = true // 勾选
      })

      savePjxx('1'); // 提交


    }, {
      once: true // 只允许提交一次
    })

  })()


  GM_addStyle(`
    .create_tit {
      display: flex;
      height: 40px;
      justify-content: space-between;
    }
    #pj-input {
      display: flex;
      align-items: center;
    }
    #pj-select{
      margin: 0 15px;
      border-radius: 0.5rem;
      height: 36px;
      width: 128px;
    }
    #pj-btn {
      cursor: pointer;
      transition: all 150ms cubic-bezier(0.4, 0, 0.2, 1);
      padding: 0.5rem 1.5rem;
      border-radius: 0.5rem;
      background-color: #fbb955;
      color: white;
      border-bottom: 4px solid #e1992e;
    }
    #pj-btn:hover {
      filter: brightness(1.1);
      transform: translateY(1px);
      border-bottom-width: 6px;
    }
    #pj-btn:active {
      filter: brightness(0.9);
      transform: translateY(2px);
      border-bottom-width: 2px;
    }
  `)
}

// 样式细节美化
if (document.URL.endsWith('welcome')) {
  GM_addStyle(`
    #ace-settings-btn {
      transform: translateY(60px);
    }
  `)
}