Greasy Fork

打破一切更新了吗

马桶哥~"MITE:打破一切"更新了吗?

当前为 2021-05-08 提交的版本,查看 最新版本

// ==UserScript==
// @name         打破一切更新了吗
// @namespace    DidMiteDPYQUpdate
// @version      1.1
// @description  马桶哥~"MITE:打破一切"更新了吗?
// @author       Rortenfeat
// @license      MulanPSL-2.0
// @include      *
// @grant        GM_xmlhttpRequest
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_openInTab
// @connect      www.mitedpyq.com
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';

	const dpyqURL = 'https://www.mitedpyq.com';
	// 每次检查更新间隔(单位:毫秒);默认值:3600000(一小时)
	const checkInterval = 3600000;

	let lastCheck = new Date(GM_getValue('dpyqTime', 0));
	let checkTime = new Date();
	let interval = checkTime.getTime() - lastCheck.getTime();
	if (!(interval < checkInterval)) {
		checkUpdate();
	}
	function checkUpdate(){
		GM_xmlhttpRequest({
			method: 'GET',
			url: dpyqURL,
			headers: {
				'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36'
			},
			onload: (data)=>{
				let html = new DOMParser().parseFromString(data.responseText, "text/html");
				let info = {
					name: html.getElementsByClassName('gon_zai_li xoa_zai')[0].innerText,
					size: html.getElementsByClassName('gon_zai_li xoa_zai')[1].innerText,
					time: html.getElementsByClassName('gon_zai_li xoa_da')[0].innerText,
					link: html.getElementsByClassName('gon_zai_li xia_an')[0].parentNode.attributes.href.value
				}
				console.log(info);
				GM_setValue('dpyqTime', checkTime);
				if ( !GM_getValue('dpyqInfo') || info.time !== GM_getValue('dpyqInfo').time ) {
					GM_setValue('dpyqInfo', info);
					if ( confirm('检测到MITE:打破一切有更新!') ) {
						GM_openInTab(dpyqURL, {active: true});
					}
				}
			}
		});
	}
})();