爱房JS脚本

可以跳转项目页,打开合同扫描件,一键下载订单明细

当前为 2022-10-08 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name                爱房JS脚本
// @namespace           http://tampermonkey.net/
// @version             0.1
// @description         可以跳转项目页,打开合同扫描件,一键下载订单明细
// @author              熊伟良
// @match               https://daiketong.58corp.com/*
// @match               https://max.58corp.com/*
// @icon                https://pages.anjukestatic.com/fe/ifang_node_admin_web/favicon.ico
// @grant               none
// @license             MIT
// ==/UserScript==

window.onload = function () {
	if (window.location.href.indexOf("commissionall") > -1) {
		setTimeout(function () {
			let el_col = document.querySelectorAll(".el-col-22")[5]
			console.log(el_col)
			let btn = document.createElement("div")
			btn.innerHTML = `<button id="关闭暗佣" class="el-button el-button--default el-button--small" style="margin-left:20px">关闭暗佣</button>`
			el_col.appendChild(btn)
			console.log(btn)
			console.log(typeof (el_col), typeof (btn))
			document.querySelector("#关闭暗佣").addEventListener("click", function () {
				let fontColorList = document.querySelectorAll(".fontColor")
				if (fontColorList.length > 0) {
					fontColorList.forEach(function (item) {
						if (item.innerText == "关闭暗佣") {
							console.log(item.innerHTML)
							item.click()
						}
					})
				}
				else {
					console.log("待加载")
					// guanbianyong()
				}
			}, false)
			console.log(el_col)
		}, 2000)

	}
	else if (window.location.href.indexOf("orderManagementFolder") > -1) {
		const cookie = document.cookie;
		// console.log(cookie)
		var bc_id = "1"
		setTimeout(function () {
			let contentList = document.querySelectorAll(".section-content-item-value")
			contentList.forEach(function (contract, contractindex) {
				let reg = /^B/
				if (reg.test(contract.innerText) == true) {
					var buildingId = contract.innerText.substring(3, 8).toString();
					var bc_code = contract.innerText;
					console.log(buildingId, bc_code);
					console.log(contentList[1])
					contentList[0].onclick = function () {
						let win = window.open(url = `https://daiketong.58corp.com/#/refactorProject/projectManager/projectManagerIndex/projectManagerDetail?building_id=${buildingId}`)
					}
					fetch("https://daiketong.58corp.com/japi/buildings/contract/list", {
						"headers": {
							"accept": "application/json, text/plain, */*",
							"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
							"authorization": "",
							"content-type": "application/json;charset=UTF-8",
							"login-type": "pc",
							"sec-ch-ua": "\"Chromium\";v=\"106\", \"Google Chrome\";v=\"106\", \"Not;A=Brand\";v=\"99\"",
							"sec-ch-ua-mobile": "?0",
							"sec-ch-ua-platform": "\"Windows\"",
							"sec-fetch-dest": "empty",
							"sec-fetch-mode": "cors",
							"sec-fetch-site": "same-origin",
							// "sw8": "1-MWE1YmNiZTAzOTE5NDIyOTk4MDgwODNhNDAwZDg2NDA=-ODNiMmUwMWU2YTc2NDMyMTkyNmQ1NTI1ZjNjZDUyNzE=-0-NTAz-aHR0cHM6Ly9kYWlrZXRvbmcuNThjb3JwLmNvbQ==-L2phcGkvYnVpbGRpbmdzL2NvbnRyYWN0L2xpc3Q=-ZGFpa2V0b25nLjU4Y29ycC5jb20=-0",
							// "sw8-correlation": "c291cmNl:YmVpZG91",
							"timestamp": "1665145024"
						},
						"referrer": "https://daiketong.58corp.com/",
						"referrerPolicy": "strict-origin-when-cross-origin",
						"body": "{\"building_id\":\"" + buildingId + "\"}",
						"method": "POST",
						"mode": "cors",
						"credentials": "include"
					}).then(res => { return res.json() }).then(json => {
						json["data"].forEach(function (item, index) {
							if (item["bc_code"] == bc_code) {
								let bc_id = item["bc_id"]
								console.log(bc_id)
								fetch("https://daiketong.58corp.com/japi/buildings/contract/get-packing-list", {
									"headers": {
										"accept": "application/json, text/plain, */*",
										"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
										"authorization": "",
										"content-type": "application/json;charset=UTF-8",
										"login-type": "pc",
										"sec-ch-ua": "\"Chromium\";v=\"106\", \"Google Chrome\";v=\"106\", \"Not;A=Brand\";v=\"99\"",
										"sec-ch-ua-mobile": "?0",
										"sec-ch-ua-platform": "\"Windows\"",
										"sec-fetch-dest": "empty",
										"sec-fetch-mode": "cors",
										"sec-fetch-site": "same-origin",
										// "sw8": "1-M2U5ZDg2OThiNWEwNDM4NTk0ZmU2OTU3OTM0NzA4NmE=-NWI3MDVlNTM5YWU5NGY3YzhjZTVhZGIyZDg2ZDc2MTc=-0-NTAz-aHR0cHM6Ly9kYWlrZXRvbmcuNThjb3JwLmNvbQ==-L2phcGkvYnVpbGRpbmdzL2NvbnRyYWN0L2dldC1wYWNraW5nLWxpc3Q=-ZGFpa2V0b25nLjU4Y29ycC5jb20=-0",
										// "sw8-correlation": "c291cmNl:YmVpZG91",
										"timestamp": "1665146852"
									},
									"referrer": "https://daiketong.58corp.com/",
									"referrerPolicy": "strict-origin-when-cross-origin",
									"body": "{\"contract_id\":" + bc_id.toString() + ",\"contract_type\":\"1\",\"status\":\"\"}",
									"method": "POST",
									"mode": "cors",
									"credentials": "include"
								}).then(res => { return res.json() }).then(json => {
									json["data"].forEach(function (item, index) {
										contract.addEventListener("click", function () {
											window.open(url = item["url"])
										}, false)
										console.log(item["url"])
									})
								})
							}
						})
					});
					console.log(bc_id, "1111");
				}
			})
		}, 1000)
		let re = setInterval(function () {
			let viewerHalf = document.querySelector(".viewerHalf")
			if (viewerHalf) {
				console.log(re)
				viewerHalf.className = "viewer-container viewer-backdrop viewer-fixed viewer-fade viewer-transition viewer-in"
				clearInterval(re)
			}
			else {
				// console.log(1)
			}
		}, 1000)
		document.onkeyup = function (event) {
			let viewer_move = document.querySelector(".viewer-move")
			if (viewer_move) {
				let a = document.documentElement.clientWidth / 2
				let b = viewer_move.style["width"].slice(0, -2) * 1 / 2
				viewer_move.style["margin-left"] = (a - b) + "px"
			}
		}
		document.onmousewheel = function (event) {
			let viewer_move = document.querySelector(".viewer-move")
			if (viewer_move) {
				let a = document.documentElement.clientWidth / 2
				let b = viewer_move.style["width"].slice(0, -2) * 1 / 2
				viewer_move.style["margin-left"] = (a - b) + "px"
			}
		}
	}
	else if (window.location.href.indexOf("max") > -1) {
		function getSystemTime(timeFormat) {
			// 实例化日期类
			var time = new Date();
			// 获取完整的年份(4位)
			var year = time.getFullYear();
			// 获取月份(0-11,0代表1月)
			var month = time.getMonth() + 1;
			month = month < 10 ? '0' + month : month;
			// 获取日期(1-31)
			var day = time.getDate();
			dd = day < 10 ? '0' + day : day;
			yd = day - 1 < 10 ? '0' + (day - 1).toString() : day - 1;
			// 获取小时
			var h = time.getHours();
			hh = h < 10 ? '0' + h : h;
			// 获取分钟
			var m = time.getMinutes();
			mm = m < 10 ? '0' + m : m;
			// 获取秒钟
			var s = time.getSeconds();
			ss = s < 10 ? '0' + s : s;
			console.log(timeFormat);
			if (timeFormat == "today") {
				var date = `${year}-${month}-${dd}`
			} else if (timeFormat == "yesterday") {
				var date = `${year}-${month}-${yd}`
			} else if (timeFormat == "mm-dd hhmm") {
				var date = `${month}-${dd} ${hh}${mm}`
			}
			console.log(date);
			return (date);
		}
		getSystemTime("today")
		let nav_topNav = document.querySelector(".topNav")
		let list = ["订单明细认购不含退户", "订单明细认购含退户", "资金流水"]
		list.forEach(element => {
			let li = document.createElement("li")
			li.innerHTML = `<button id="${element}">${element}</button>`
			nav_topNav.appendChild(li)
		});
		async function getToken() {
			let res = await fetch("https://max.58corp.com/chart/view/4257", {
				"headers": {
					"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
					"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
					"cache-control": "max-age=0",
					"sec-ch-ua": "\".Not/A)Brand\";v=\"99\", \"Google Chrome\";v=\"103\", \"Chromium\";v=\"103\"",
					"sec-ch-ua-mobile": "?0",
					"sec-ch-ua-platform": "\"Windows\"",
					"sec-fetch-dest": "document",
					"sec-fetch-mode": "navigate",
					"sec-fetch-site": "same-origin",
					"sec-fetch-user": "?1",
					"upgrade-insecure-requests": "1"
				},
				"referrer": "https://max.58corp.com/chart/view/4493",
				"referrerPolicy": "strict-origin-when-cross-origin",
				"body": null,
				"method": "GET",
				"mode": "cors",
				"credentials": "include"
			})
			let text = await res.text()
			var token = text.match(/Token=(.*?),/)[1]
			console.log(token)
			function download(id, fileName) {
				fetch("https://datamap.58.com/report/order/download?downloadId=" + id + "&fileName=" + fileName + "", {
					"headers": {
						"accept": "*/*",
						"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
						"content-type": "application/json",
						"responsetype": "blob",
						"sec-ch-ua": "\".Not/A)Brand\";v=\"99\", \"Google Chrome\";v=\"103\", \"Chromium\";v=\"103\"",
						"sec-ch-ua-mobile": "?0",
						"sec-ch-ua-platform": "\"Windows\"",
						"sec-fetch-dest": "empty",
						"sec-fetch-mode": "cors",
						"sec-fetch-site": "cross-site",
						"token": token
					},
					"referrer": "https://max.58corp.com/",
					"referrerPolicy": "strict-origin-when-cross-origin",
					"body": null,
					"method": "GET",
					"mode": "cors",
					"credentials": "omit"
				}).then(res => res.blob().then(blob => {
					let url = window.URL.createObjectURL(blob)
					let a = document.createElement('a')
					a.style.display = 'none'
					a.href = url
					a.download = fileName + ".xlsx"
					document.body.appendChild(a)
					a.click()
					document.body.removeChild(a)
					window.URL.revokeObjectURL(url)
				}))
			}
			function getExcelId(fileName) {
				fetch("https://datamap.58.com/report/order/list?page=1&limit=1000&key=" + fileName + "&menuId=1154", {
					"headers": {
						"accept": "*/*",
						"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
						"content-type": "application/json",
						"sec-ch-ua": "\".Not/A)Brand\";v=\"99\", \"Google Chrome\";v=\"103\", \"Chromium\";v=\"103\"",
						"sec-ch-ua-mobile": "?0",
						"sec-ch-ua-platform": "\"Windows\"",
						"sec-fetch-dest": "empty",
						"sec-fetch-mode": "cors",
						"sec-fetch-site": "cross-site",
						"token": token
					},
					"referrer": "https://max.58corp.com/",
					"referrerPolicy": "strict-origin-when-cross-origin",
					"body": null,
					"method": "GET",
					"mode": "cors",
					"credentials": "omit"
				}).then(res => {
					return res.json()
				}).then(json => {
					let id = json["page"]["list"][0]["id"].toString()
					let status = json["page"]["list"][0]["status"]
					console.log(status)
					console.log(json)
					if (status != 2) {
						getExcelId(fileName)
					}
					else {
						download(id, fileName)
					}

				});

			}
			function getExcel(fileName, body) {
				fetch("https://datamap.58.com/report/order/export", {
					"headers": {
						"accept": "*/*",
						"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
						"content-type": "application/json",
						"sec-ch-ua": "\".Not/A)Brand\";v=\"99\", \"Google Chrome\";v=\"103\", \"Chromium\";v=\"103\"",
						"sec-ch-ua-mobile": "?0",
						"sec-ch-ua-platform": "\"Windows\"",
						"sec-fetch-dest": "empty",
						"sec-fetch-mode": "cors",
						"sec-fetch-site": "cross-site",
						"token": token
					},
					"referrer": "https://max.58corp.com/",
					"referrerPolicy": "strict-origin-when-cross-origin",
					"body": body,
					"method": "POST",
					"mode": "cors",
					"credentials": "omit"
				}).then(res => {
					return res.json()
				}).then(json => {
					console.log(json.msg)
					if (json.msg != "success") { getExcel(fileName, body.replace(today, yesterday)) } else {
						getExcelId(fileName)
					}
				}
				);
			}


			var queryColumns = `[1, 3, 5, 7, 2, 4, 323, 324, 1085, 964, 6, 325, 8, 9, 10, 11, 12, 13, 730, 1025, 14, 15, 326, 16, 17, 18, 19, 20, 21, 22, 23, 24, 528, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 731, 732, 733, 734, 735, 736, 737, 757, 39, 761, 40, 43, 121, 122, 899, 900, 902, 1242, 901, 1088, 1087, 44, 762, 45, 46, 1022, 327, 328, 47, 329, 48, 49, 50, 1080, 51, 763, 965, 966, 967, 1029, 1030, 1278, 1277, 960, 961, 962, 963, 58, 336, 59, 60, 61, 337, 62, 63, 64, 65, 66, 67, 1023, 68, 69, 1024, 70, 691, 71, 1063, 1279, 1280, 1281, 72, 73, 74, 75, 76, 320, 77, 78, 79, 321, 80, 81, 82, 83, 84, 85, 93, 94, 95, 96, 97, 322, 98, 99, 100, 101, 102, 103, 104, 105, 107, 109, 110, 111, 112, 113, 114, 115, 116, 330, 331, 332, 333, 334, 335, 898, 1216, 1217, 1218, 1219, 1220, 1221, 334, 760, 1029, 1237, 1250, 1258, 328, 329, 334, 757, 760, 1029, 1244, 1237, 1250, 1258]`
			var refundStatus = `[0,1,2,3]`
			var today = getSystemTime("today")
			var yesterday = getSystemTime("yesterday")
			let rengoubutui = document.querySelector("#订单明细认购不含退户")
			rengoubutui.onclick = function () {
				let fileName = getSystemTime("mm-dd hhmm") + " 订单明细(认购)"
				var refundStatus = `[0,1,2]`
				var body = "{\"fileName\":\"" + fileName +
					"\",\"calDt\":\"" + today + "\",\"buildingRegionId\":-1,\"buildingCityId\":-1,\"orderStatus\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14],\"ssStatus\":[0,2,3,1,4,5],\"refundStatus\":" + refundStatus + ",\"receivableStatus\":[0,1,2],\"settlementType\":[1,2,0,3,-99],\"prepaidType\":[1,-99,0],\"queryColumns\":" + queryColumns + ",\"menuId\":1153,\"cusErr\":true,\"subscribeTime\": [\"2021-01-01\", \"2023-01-01\"]}"
				console.log(body)
				getExcel(fileName = fileName, body = body)
			}
			let rengoutui = document.querySelector("#订单明细认购含退户")
			rengoutui.onclick = function () {
				let fileName = getSystemTime("mm-dd hhmm") + " 订单明细(认购含退户)"
				var refundStatus = `[0,1,2,3]`
				var body = "{\"fileName\":\"" + fileName +
					"\",\"calDt\":\"" + today + "\",\"buildingRegionId\":-1,\"buildingCityId\":-1,\"orderStatus\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14],\"ssStatus\":[0,2,3,1,4,5],\"refundStatus\":" + refundStatus + ",\"receivableStatus\":[0,1,2],\"settlementType\":[1,2,0,3,-99],\"prepaidType\":[1,-99,0],\"queryColumns\":" + queryColumns + ",\"menuId\":1153,\"cusErr\":true,\"subscribeTime\": [\"2021-01-01\", \"2023-01-01\"]}"
				console.log(body)
				getExcel(fileName = fileName, body = body)
			}


		}
		getToken()






	}


};