// ==UserScript== // @name 北化网课雨 // @namespace http://tampermonkey.net/ // @version 0.2.1 // @description try to take over the world! // @author Snowman // @match https://buct.yuketang.cn/pro/*/*/*/video/* // @icon https://www.google.com/s2/favicons?sz=64&domain=yuketang.cn // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; function CloseWindow() { var userAgent = navigator.userAgent; if (userAgent.indexOf("Firefox") != -1 || userAgent.indexOf("Chrome") != -1) { window.location.href = "about:blank"; window.close(); } else { window.opener = null; window.open("", "_self"); window.close(); } } var EleManager = { Register: function (name, selector) { if (this[name] == undefined) { this[name] = document.querySelector(selector); } } }; function Init() { document.hasFocus = el_psy_congroo => true; setTimeout(() => { EleManager.Register("title", "#app > div.app-wrapper > div.wrap > div.viewContainer.heightAbsolutely > div > div.video-wrap > div.box > div > section.title > div.title-fl"); EleManager.title.innerHTML += `
(已黑化)
`; EleManager.Register("rate", "#sg-rate"); console.log("完成了喵~"); }, 1000); //setInterval(() => { // let n = window.rate; // EleManager.rate.innerText = n; // if (n >= 1) CloseWindow(); //}, 1000) var el; setInterval(()=>{ if (el == undefined) { el = document.querySelector("#app > div.app-wrapper > div.wrap > div.viewContainer.heightAbsolutely > div > div.video-wrap > div.box > div > section.title > div.title-fr > div > div > span"); if (el == undefined) { document.title = "无法获取进度!" return; } } let n = Number(el.innerText.slice(4,-1)); document.title = "进度:" + n + "%"; if (n >= 100) { document.title = "已完成!" setTimeout(CloseWindow, 500); } }, 1000); } Init(); // Your code here... })();