添加 'tbk/supercircle.user.js'
This commit is contained in:
parent
10ce31c2e0
commit
1100dd3ecb
211
tbk/supercircle.user.js
Normal file
211
tbk/supercircle.user.js
Normal file
@ -0,0 +1,211 @@
|
||||
// ==UserScript==
|
||||
// @name 淘宝客自动数据上报
|
||||
// @namespace https://tbk.yumc.pw/
|
||||
// @version 0.1
|
||||
// @description 自动收集淘宝客数据上报服务端
|
||||
// @author MiaoWoo
|
||||
// @match https://pub.alimama.com/manage/effect/overview_orders.htm**
|
||||
// @match https://pub.alimama.com//openapi/param2/1/gateway.unionpub/report.getTbkOrderDetails.json/_____tmd_____/punish**
|
||||
// @match https://www.alimama.com/member/login.htm**
|
||||
// @match https://login.taobao.com/member/login.jhtml**
|
||||
// @match https://pub.meituan.com**
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
|
||||
(function () {
|
||||
'use strict'
|
||||
Date.prototype.format = function (fmt) {
|
||||
var o = {
|
||||
"M+": this.getMonth() + 1,
|
||||
"d+": this.getDate(),
|
||||
"h+": this.getHours(),
|
||||
"m+": this.getMinutes(),
|
||||
"s+": this.getSeconds(),
|
||||
"q+": Math.floor((this.getMonth() + 3) / 3),
|
||||
"S": this.getMilliseconds()
|
||||
}
|
||||
if (/(y+)/.test(fmt)) {
|
||||
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length))
|
||||
}
|
||||
for (var k in o) {
|
||||
if (new RegExp("(" + k + ")").test(fmt)) {
|
||||
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)))
|
||||
}
|
||||
}
|
||||
return fmt
|
||||
}
|
||||
var params = location.search.split('&').map(s => s.split('=')).reduce((pre, cur, index) => { pre[cur[0]] = cur[1]; return pre }, {})
|
||||
var today = new Date().format('yyyy-MM-dd')
|
||||
var referrer = "https://pub.alimama.com/manage/effect/overview_orders.htm?jumpType=0&positionIndex=&pageNo=1&startTime=" + today + "&endTime=" + today + "&queryType=1"
|
||||
async function sleep(time) {
|
||||
return new Promise((resolve, reject) => setTimeout(resolve, time))
|
||||
}
|
||||
async function alimamaRefresh(today) {
|
||||
location.href = "https://pub.alimama.com/manage/effect/overview_orders.htm?jumpType=0&positionIndex=&pageNo=1&startTime=" + today + "&endTime=" + today + "&queryType=1"
|
||||
}
|
||||
async function post(method, data) {
|
||||
return await fetch('https://tbk.yumc.pw/callback/' + method, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
"mode": "cors",
|
||||
"credentials": "include"
|
||||
}).then(r => r.json())
|
||||
}
|
||||
async function reportOrders(date) {
|
||||
let trigger = document.querySelectorAll('.mx-trigger')[1]
|
||||
if (!trigger) {
|
||||
return setTimeout(() => reportOrders(date), 300)
|
||||
}
|
||||
let taskId = setTimeout(async () => {
|
||||
//document.getElementById('nickDrop').nextElementSibling.click()
|
||||
//await sleep(1000)
|
||||
return alimamaRefresh(today)
|
||||
}, 45000)
|
||||
trigger.click()
|
||||
await sleep(500)
|
||||
let orders = await fetch("https://pub.alimama.com/openapi/param2/1/gateway.unionpub/report.getTbkOrderDetails.json?queryType=1&startTime=" + date + "&endTime=" + date + "&pageNo=1&pageSize=100&jumpType=0", {
|
||||
"headers": {
|
||||
"accept": "*/*",
|
||||
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
|
||||
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
"sec-ch-ua": "\" Not;A Brand\";v=\"99\", \"Microsoft Edge\";v=\"91\", \"Chromium\";v=\"91\"",
|
||||
"sec-ch-ua-mobile": "?0",
|
||||
"sec-fetch-dest": "empty",
|
||||
"sec-fetch-mode": "cors",
|
||||
"sec-fetch-site": "same-origin",
|
||||
"x-requested-with": "XMLHttpRequest"
|
||||
},
|
||||
"referrer": referrer,
|
||||
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||
"body": null,
|
||||
"method": "GET",
|
||||
"mode": "cors",
|
||||
"credentials": "include"
|
||||
}).then(r => r.json())
|
||||
trigger.click()
|
||||
if (!orders.success) {
|
||||
return console.log(orders)
|
||||
}
|
||||
clearTimeout(taskId)
|
||||
await post('alimama', orders)
|
||||
post('alimama', await fetch("https://pub.alimama.com/openapi/param2/1/gateway.unionpub/report.getTbkOrderDetails.json?queryType=3&startTime=" + date + "&endTime=" + date + "&pageNo=1&pageSize=100&jumpType=0", {
|
||||
"headers": {
|
||||
"accept": "*/*",
|
||||
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
|
||||
"content-type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
"sec-ch-ua": "\" Not;A Brand\";v=\"99\", \"Microsoft Edge\";v=\"91\", \"Chromium\";v=\"91\"",
|
||||
"sec-ch-ua-mobile": "?0",
|
||||
"sec-fetch-dest": "empty",
|
||||
"sec-fetch-mode": "cors",
|
||||
"sec-fetch-site": "same-origin",
|
||||
"x-requested-with": "XMLHttpRequest"
|
||||
},
|
||||
"referrer": referrer,
|
||||
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||
"body": null,
|
||||
"method": "GET",
|
||||
"mode": "cors",
|
||||
"credentials": "include"
|
||||
}).then(r => r.json()))
|
||||
post('message', { message: '' })
|
||||
console.log(new Date().toLocaleTimeString(),'阿里妈妈数据上报完成!')
|
||||
}
|
||||
async function taobaoLogin() {
|
||||
await sleep(1000)
|
||||
let login_id = document.getElementById('fm-login-id')
|
||||
login_id.click()
|
||||
login_id.value = 'tb5995076_11'
|
||||
await sleep(800)
|
||||
let password = document.getElementById('fm-login-password')
|
||||
password.click()
|
||||
password.value = 'Jtb2hwwfor'
|
||||
await sleep(300)
|
||||
document.querySelector('.password-login').click()
|
||||
}
|
||||
async function meituan(date) {
|
||||
let orders = await fetch("https://pub.meituan.com/benchmark/order/detail/cps", {
|
||||
"headers": {
|
||||
"Content-Type": "application/json;charset=utf-8",
|
||||
},
|
||||
"referrer": "https://pub.meituan.com/",
|
||||
"referrerPolicy": "strict-origin-when-cross-origin",
|
||||
"body": JSON.stringify({ "pageIndex": 1, "pageSize": 200, "queryTimeType": 1, "itemBizStatus": 0, "beginTime": date, "endTime": date }),
|
||||
"method": "POST",
|
||||
"mode": "cors",
|
||||
"credentials": "include"
|
||||
}).then(r => r.json())
|
||||
post('meituan', orders)
|
||||
post('mtMtz', {})
|
||||
console.log(new Date().toLocaleTimeString(),'美团数据上报完成!')
|
||||
await post('htt', { type: 2, scene: 2 })
|
||||
await post('htt', { type: 2 })
|
||||
post('htt', { type: 3 })
|
||||
console.log(new Date().toLocaleTimeString(),'花推推数据上报完成!')
|
||||
document.querySelector('.data-analysis-tips').innerText = new Date().toLocaleTimeString() + " 外卖神圈 数据上报完成!"
|
||||
}
|
||||
async function randomSleep(random = 600000) {
|
||||
await sleep(Math.random() * random + 60000)
|
||||
}
|
||||
function setLastPostMessageTime() {
|
||||
window.localStorage.lastPostMessageTime = Date.now()
|
||||
}
|
||||
function getLastPostMessageTime() {
|
||||
return Date.now() - (window.localStorage.lastPostMessageTime || 0)
|
||||
}
|
||||
function postMessage(message){
|
||||
if (getLastPostMessageTime() > 10800000) {
|
||||
post('message', { message: message})
|
||||
setLastPostMessageTime()
|
||||
}
|
||||
}
|
||||
async function main() {
|
||||
if (location.href.startsWith('https://login.taobao.com')) {
|
||||
await taobaoLogin()
|
||||
return
|
||||
}
|
||||
if(location.href.startsWith('https://www.alimama.com/member/login.htm')){
|
||||
setTimeout(()=> {
|
||||
postMessage('阿里妈妈页面出现滑动验证码!')
|
||||
alimamaRefresh(new Date().format('yyyy-MM-dd'))
|
||||
}, 30000)
|
||||
}
|
||||
if (location.href.startsWith('https://pub.alimama.com/manage/effect/overview_orders.htm')) {
|
||||
await sleep(2000)
|
||||
// for (let i = 0; i < 10; i++) {
|
||||
try {
|
||||
await sleep(500)
|
||||
await reportOrders(today)
|
||||
await randomSleep()
|
||||
} catch (ex) {
|
||||
post('message', { message: '阿里妈妈数据上报异常: ' + ex })
|
||||
}
|
||||
// }
|
||||
alimamaRefresh(new Date().format('yyyy-MM-dd'))
|
||||
return
|
||||
}
|
||||
if (location.href.startsWith('https://pub.meituan.com/') && location.hash == "#/performance-report") {
|
||||
await sleep(2000)
|
||||
for (let i = 0; i < 10; i++) {
|
||||
try {
|
||||
await sleep(500)
|
||||
await meituan(today)
|
||||
await randomSleep(60000)
|
||||
} catch (ex) {
|
||||
post('message', { message: '美团数据上报异常: ' + ex })
|
||||
}
|
||||
}
|
||||
location.reload()
|
||||
return
|
||||
}
|
||||
if (location.href.startsWith('https://pub.alimama.com//openapi/param2/1/gateway.unionpub/report.getTbkOrderDetails.json/_____tmd_____/punish')) {
|
||||
setTimeout(()=> {
|
||||
postMessage('阿里妈妈页面出现滑动验证码!')
|
||||
}, 10000)
|
||||
}
|
||||
}
|
||||
main()
|
||||
})()
|
Loading…
Reference in New Issue
Block a user