您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatically reloads the page at the end of each race.
// ==UserScript==
// @name NitroType Auto Reload for windows 7, XP, and more (Older PC's that don't load instantly
// @author Ray Adams / TheGoatJack1
// @namespace https://github.com/Ray-Adams
// @description Automatically reloads the page at the end of each race.
// @version 2.1.0
// @match *://*.nitrotype.com/race
// @match *://*.nitrotype.com/race/*
// @homepageURL https://github.com/Ray-Adams/NitroType-Archive
// @run-at document-end
// @grant none
// @license MIT
// ==/UserScript==
const options = {
timerMs: 400, // slight delay to make sure the race gets logged
reloadWhenDisqualified: true
};
const returnToGarageBtn = document.querySelector('.btn--secondary[href="/garage"]');
const raceContainer = document.getElementById('raceContainer');
const dashCenter = document.querySelector('.dash-center');
// Watch for error modal
const dqObserver = new MutationObserver((mutationList, observer) => {
mutationList.forEach(mutation => {
mutation.addedNodes.forEach(node => {
if (!node.classList.contains('modal--error')) return;
observer.disconnect();
location.reload();
});
});
});
if (options.reloadWhenDisqualified) {
dqObserver.observe(raceContainer, { childList: true });
}
// Prevent button from firing the dqObserver (bug fix)
returnToGarageBtn.addEventListener('click', () => {
dqObserver.disconnect();
});
// Watch for class changes on the last letter
const lastLetterObserver = new MutationObserver(mutationList => {
mutationList.forEach(mutation => {
if (!mutation.target.classList.contains('is-correct')) return;
lastLetterObserver.disconnect();
setTimeout(() => location.reload(), options.timerMs);
});
});
// Wait for the dashboard to load before observing the lesson text
const lessonObserver = new MutationObserver((mutationList) => {
mutationList.forEach(mutation => {
mutation.addedNodes.forEach(node => {
if (node.className !== 'dash-copyContainer') return;
const letters = document.querySelectorAll('.dash-letter');
const lastLetter = letters[letters.length - 2];
lessonObserver.disconnect();
lastLetterObserver.observe(lastLetter, { attributes: true });
});
});
});
lessonObserver.observe(dashCenter, { childList: true });
console.info('\'NitroType Auto Reload\' is no longer maintained, see https://github.com/Ray-Adams/NitroType-Archive for more info.');