您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
重庆高教平台自动刷网课,不包含答题
当前为
// ==UserScript== // @name 刷课|重庆高等教育智慧教育平台|重庆智慧教育平台 cqooc.com www.cqooc.com // @namespace https://github.com/qinikat // @version 0.3.0 // @description 重庆高教平台自动刷网课,不包含答题 // @author ikat易卡 // @match https://www.cqooc.com/* // @grant none // @license MIT // ==/UserScript== ;(function () { ;('use strict') showStartBtn() function isCqooc() { if ( window.location.host == 'www.cqooc.com' && window.location.pathname == '/learn/mooc/structure' ) { console.log('cqooc自动刷课脚本加载成功') return true } else { console.log('请在https://www.cqooc.com/下使用此脚本,并进入相应的课程') alert('请在https://www.cqooc.com/下使用此脚本,并进入相应的课程') window.location.href = 'https://www.cqooc.com/my/learn' return false } } function AutoStudy() { let chaptersList = document.querySelector('ul.cont_list#chapters-list') if (chaptersList) { let chapterShead = chaptersList.querySelectorAll('li.item.one.close') chapterShead.forEach((item) => { item.click() }) } else { return null } //let regex = /item\s+ref_\d+\s+item\d+\s+two\s+(?!s8)\w+/ let regex = /item\s+ref_\d+\s+item\d+\s+two\s+s(0|1|2|3|4|5)/ let sections = document.querySelectorAll('li') let studyList = [] sections.forEach((item) => { if (regex.test(item.className)) { studyList.push(item) } }) console.log(studyList.length) async function study() { for (let i = 0; i < studyList.length; i++) { let currentSection = studyList[i] console.log('Current section:', currentSection) currentSection.querySelector('a').click() await AwaitElementLoaded() await delay(2000) let slide_list = document.querySelector('ul.list') if (!slide_list) { console.log('slide_list not found') throw new Error('slide_list not found') } console.log(slide_list) let slides = slide_list.querySelectorAll('li') if (!slides) { console.log('slides not found') throw new Error('slides not found') } console.log(slides) for (let j = 0; j < slides.length; j++) { let CurrentSlide = slides[j] console.log(CurrentSlide) CurrentSlide.click() await AwaitElementLoaded() await delay(2000) if (CurrentSlide.className.includes('v2')) { let countText = document.querySelector('#countText') if (!countText) { console.log('countText not found') throw new Error('countText not found') } if (countText.querySelector('span')) { console.log('视频已完成') continue } else { console.log('视频未完成') PlayVideo() await delay(35000) } } else if (CurrentSlide.className.includes('v1')) { let countText = document.querySelector('#countText') if (!countText) { console.log('countText not found') throw new Error('countText not found') } if (countText.querySelector('span').innerText == '已完成') { console.log('课件已完成') continue } else { console.log('课件未完成') await delay(35000) } } else { console.log('未知类型') await delay(3000) continue } } } } study() function delay(ms) { return new Promise((resolve) => setTimeout(resolve, ms)) } function PlayVideo() { let playIconDiv = document.querySelector('div.xgplayer-icon-play') if (playIconDiv) { let svgElement = playIconDiv.querySelector('svg') svgElement.addEventListener('click', function () { console.log('SVG element clicked!') }) function simulateClick(target) { let event = new MouseEvent('click', { view: window, bubbles: true, cancelable: true, }) target.dispatchEvent(event) } simulateClick(svgElement) } else { console.error('Element with class xgplayer-icon-play not found!') } } function AwaitElementLoaded(timeout = 60000, interval = 1000) { return new Promise((resolve, reject) => { let elapsedTime = 0 const checkElementLoaded = async () => { let video = document.querySelector('#videoPlayer') let courseware = document.querySelector('div.MPreview-box') if (video || courseware) { resolve(true) } else { elapsedTime += interval if (elapsedTime >= timeout) { reject(new Error('Resource loading timed out')) } else { await delay(interval) checkElementLoaded() } } } checkElementLoaded() }) } } function showStartBtn() { let startBtn = document.createElement('button') startBtn.style.position = 'fixed' startBtn.style.top = '420px' startBtn.style.left = '50px' startBtn.style.zIndex = '9999' startBtn.style.width = '200px' startBtn.style.height = '100px' startBtn.style.backgroundImage = 'url(https://avatars.githubusercontent.com/u/132556483?v=4)' startBtn.style.backgroundSize = 'cover' startBtn.style.backgroundPosition = 'center' startBtn.style.color = 'white' startBtn.style.border = 'none' startBtn.style.borderRadius = '5px' startBtn.style.fontSize = '16px' startBtn.style.cursor = 'pointer' startBtn.style.outline = 'none' startBtn.style.padding = '10px' startBtn.style.textShadow = '1px 1px 2px black' startBtn.style.display = 'flex' startBtn.style.flexDirection = 'column' startBtn.style.justifyContent = 'center' startBtn.style.alignItems = 'center' let mainText = document.createElement('div') mainText.innerText = '点这里开始自动学习' mainText.style.marginTop = '20px' startBtn.appendChild(mainText) let authorText = document.createElement('span') authorText.innerText = 'by.ikat易卡' authorText.style.fontSize = '12px' authorText.style.marginTop = '12px' startBtn.appendChild(authorText) startBtn.addEventListener('click', () => { if (!isCqooc()) { return } AutoStudy() }) document.body.appendChild(startBtn) } })()