Pinnacle Optimize

hdu pinnacle刷题网站的优化脚本。

اعتبارا من 16-06-2023. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Pinnacle Optimize
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  hdu pinnacle刷题网站的优化脚本。
// @author       Lycoiref
// @match        *://pinnacle-primary-fe.mjclouds.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=mjclouds.com
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
// hdu pinnacle刷题网站优化脚本
window.onload = async () => {
    await new Promise((resolve) => {
        setTimeout(resolve, 100)
    })
    while(!document.querySelector('.items-center') || !document.querySelector('button') || !document.querySelector('.whitespace-pre-line')) {
        await new Promise((resolve) => {
            setTimeout(resolve, 100)
        })
    }
    try {
        options
        window.location.reload()
    } catch (e) {
    }
    let options = document.querySelectorAll('.items-center')
    let btns = document.querySelectorAll('button')
    let question = document.querySelector('.whitespace-pre-line')
    setInterval(() => {
        let cards = document.querySelectorAll('p')
        cards.forEach((card) => {
            if (card.innerText==='题库市场') {
                window.location.reload()
            }
        })
    }, 100)

    window.addEventListener('keypress', (e) => {
        // QWER分别对应1234个选项
        switch (e.key) {
            case 'q':
                options[0].click()
                break
            case 'w':
                options[1].click()
                break
            case 'e':
                options[2].click()
                break
            case 'r':
                options[3].click()
                break
        }
        // 空格键对应下一题
        if (e.key === ' ') {
            if (btns[1].attributes['disabled']) {
                btns[2].click()
                // 清除focus
                document.activeElement.blur()
            } else {
                btns[1].click()
            }
        }
    })

    // 创建对question的观察进程
    let observerOptions = {
        childList: true,
        subtree: true,
        attributes: true,
        // 监听innerHTML的变化
        characterData: true
    }
    let observer = new MutationObserver((mutations) => {
        console.log('question changed')
        options = document.querySelectorAll('.items-center')
    })

    observer.observe(question, observerOptions)
}




})();