某东,某喜-收取电力

2020/3/28 下午4:51:41

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        某东,某喜-收取电力
// @namespace   Violentmonkey Scripts
// @match       https://wqs.jd.com/pingou/dream_factory/*.html
// @match       https://wqs.jd.com/pingou/dream_factory/*.html?*
// @match       https://wqs.jd.com/pingou/dream_factory/market.html
// @match       https://wqs.jd.com/pingou/dream_factory/market.html?*
// @grant       none
// @version     1.4
// @author      zhangdaren([email protected])
// @update      smilewind([email protected])
// @description 2020/3/28 下午4:51:41
// ==/UserScript==

(function() {
	console.log('奥利给!!!京喜工厂自动收取双倍电力,开干~');
	setTimeout(function(){
			lifecycle();
	}, 2000);
})();

function lifecycle() {
	let timeid = setInterval(function() {
		if (document.querySelector(".alternator-num-n")) {
			var num = document.querySelector(".alternator-num-n").innerText;
			console.log("监测电力值 ->> " + num);
			num = parseFloat(num);
			if (num >= 300) {
				console.log("电力值到300啦")
				document.getElementById("alternator").click();
				document.getElementsByClassName('simple_dialog_txt_btn_txt')[0].click();
                document.getElementsByClassName('close')[0].click();
				//clearInterval(timeid);
				//setTimeout(function() {
					//document.querySelector(".simple_dialog_btn").click();
					//lifecycle();
				//}, 1000)
			}
		} else if (document.querySelector(".floating_title")) {
			var secStr = document.querySelector(".floating_title").innerText;
			console.log("监测倒计时 ->> " + secStr);			
			if (secStr === "已完成") {
				console.log("完成啦")
				document.querySelector(".floating_title").click();
				clearInterval(timeid);
				setTimeout(function() {
					lifecycle();
				}, 2000)
			} else if (secStr === "30s") {
				console.log("滑动页面")
				document.querySelector(".scroll-view").scrollTo(0, 800);
			}
		}
	}, 1000);
}