window.userSt = {}
// 监听拦截到的数据
window.onInterceptedData = function (data) {
console.log(data)
window.systemInfo = data
switch (data.url) {
case "https://utas.mob.v5.prd.futc-ext.gcp.ea.com/ut/auth":
const result = JSON.parse(data.responseBody)
if (result.sid) {
window.activeID = result.sid
if (window.logBox) window.logBox.add('获取到认证ID:' + window.activeID)
}
break;
default:
break;
}
if (data.url.includes('https://utas.mob.v5.prd.futc-ext.gcp.ea.com/ut/game/fc26/auctionhouse')) {
console.log(data)
const result2 = data.requestBody
window.itemID = result2.itemData.id
if (window.logBox) window.logBox.add(`卖出物品:${window.itemID}`)
if (window.userSt[window.itemID]) {
window.logBox.add(`获取到物品ID:${window.userSt[window.itemID].assetId}`)
owoSocket.send("sell", {"id": window.itemID, "buyNowPrice": result2.buyNowPrice, "assetId": window.userSt[window.itemID].assetId})
} else {
window.logBox.add(`无法匹配物品:${window.itemID}`)
}
}
if (data.url.includes('https://utas.mob.v5.prd.futc-ext.gcp.ea.com/ut/game/fc26/tradepile')) {
const result3 = JSON.parse(data.responseBody)
if (window.logBox) window.logBox.add(`获取到物品数量:${result3.auctionInfo.length}`)
result3.auctionInfo.forEach(element => {
window.userSt[element.itemData.id] = element.itemData
});
}
if (data.url.includes('https://utas.mob.v5.prd.futc-ext.gcp.ea.com/ut/game/fc26/trade/') && data.url.includes('/bid')) {
const result4 = JSON.parse(data.responseBody)
if (window.logBox) window.logBox.add(`新库存物品:${result4.auctionInfo[0].tradeId}`)
window.userSt[result4.auctionInfo[0].itemData.id] = result4.auctionInfo[0].itemData
}
};
let owoLoadList = []
function loadCSS (url) {
if (owoLoadList.includes(url)) {
return
}
owoLoadList.push(url)
var link = document.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.href = url;
document.getElementsByTagName("head")[0].appendChild(link);
}
setTimeout(() => {
var box = document.getElementsByClassName('puge-box')
if (!box[0]) {
var insertElement = document.createElement("div");
insertElement.style.display = 'none'
insertElement.classList.add('puge-box')
insertElement.style.zIndex = '9665'
insertElement.style.width = '300px'
insertElement.style.height = '560px'
insertElement.style.position = 'fixed'
insertElement.style.right = '0'
insertElement.style.top = '0'
insertElement.style.fontSize = '18px'
insertElement.style.lineHeight = '30px'
insertElement.style.padding = '10px'
insertElement.style.backgroundColor = 'white'
document.body.appendChild(insertElement);
if (window.pugeCreated) {
window.pugeCreated(insertElement)
window.pugeCreated = null
}
}
}, 1000)
var box = document.getElementsByClassName('puge-menu')
if (!box[0]) {
var insertElement = document.createElement("div");
insertElement.classList.add('puge-menu')
insertElement.innerHTML = `
`
document.body.appendChild(insertElement);
}
function owostart () {
const box = document.getElementsByClassName('puge-box')[0]
// alert(box.style.display)
if (box.style.display == 'none') {
box.style.display = 'block'
if (window.pugeCreated) {
window.pugeCreated(document.getElementsByClassName('puge-box')[0])
window.pugeCreated = null
}
} else {
box.style.display = 'none'
}
window.loadingDialog = function () {
return
}
}
function logPanel (el, max) {
if (el) {
el.innerHTML = ''
setTimeout(() => {
this.$el = el.querySelector('.log-panel-w')
}, 0);
}
this.max = max || 100
this.list = []
this.add = function (text) {
if (!text) text = ''
var time = new Date();
let hours = time.getHours()
if (hours <= 9) hours = '0' + hours
let minutes = time.getMinutes()
if (minutes <= 9) minutes = '0' + minutes
let seconds = time.getSeconds()
if (seconds <= 9) seconds = '0' + seconds
this.list.push([`${hours}:${minutes}:${seconds}`, text])
if (this.list.length > this.max) {
this.list = this.list.slice(1)
}
this.make()
}
this.make = function () {
let newHtml = ''
for (let index = this.list.length - 1; index >= 0; index--) {
const element = this.list[index];
newHtml += `${element[0]}${element[1]}`
}
setTimeout(() => {
this.$el.innerHTML = newHtml
}, 0);
}
}
setTimeout(() => {
if (document.querySelector('.puge-box')) document.querySelector('.puge-box').innerHTML = `
开始接收
停止接收
日志输出
`
setTimeout(() => {
window.logBox = new logPanel(document.querySelector('.log-panel'))
}, 0);
}, 2000);
function owoSocket(typeStr, options) {
const that = this
this.type = typeStr
let timeConnect = 0;
function reconnect(callBack) {
timeConnect++;
console.log("第" + timeConnect + "次重连");
// 普通连接
that.ws = new WebSocket('wss://ws.lamp.run')
that.ws.addEventListener('open', function (event) {
that.ws.send(JSON.stringify({"route": "login", "type": typeStr, "admin": options.isAdmin, "id": options.id}))
if (callBack) callBack()
if (options.onOpen) options.onOpen(that.ws)
})
that.ws.onerror = function () {
console.error('服务器已经断开');
// 进行重连
setTimeout(function () {
reconnect();
}, 3000)
};
that.ws.addEventListener('message', function (event) {
const mess = JSON.parse(event.data)
if (mess.type === 'userInfo') {
that.wsUserInfo = mess.value
if (options.onReady) options.onReady(that.ws)
} else {
if (options.messageCallBack) options.messageCallBack(mess)
}
})
}
reconnect()
this.send = function (route, value, sendTo) {
// 先判断连接是否关闭 如果关闭先重新连接
if (that.ws.readyState === 3) {
console.error('ws连接已断开正在重连!')
reconnect(()=> {
that.ws.send(JSON.stringify({"route": route, "type": typeStr, "userID": that.wsUserInfo.userID, "id": sendTo, "value": value}))
})
} else {
that.ws.send(JSON.stringify({"route": route, "type": typeStr, "userID": that.wsUserInfo.userID, "id": sendTo, "value": value}))
}
}
}
function searchItem(itemInfo, callBack) {
// 查找ID
window.logBox.add(`开始购买:${JSON.stringify(playerInfo)}`)
fetch(`https://utas.mob.v5.prd.futc-ext.gcp.ea.com/ut/game/fc26/transfermarket?num=21&start=0&type=player&maskedDefId=${itemInfo.assetId}&minb=${itemInfo.buyNowPrice}&maxb=${itemInfo.buyNowPrice + 50}`, {
"headers": {
"accept": "*/*",
"accept-language": "zh-CN",
"content-type": "application/json",
"x-ut-sid": window.activeID
},
"referrer": "https://www.ea.com/",
"body": null,
"method": "GET",
}).then((response) => response.json())
.then((result) => {
let resp = '搜索到列表:'
result.auctionInfo.forEach(element => {
resp += `[${element.itemData.id}]`
if(element.itemData.id == itemInfo.id) {
window.logBox.add(`获取到商品ID:${element.tradeId}`)
callBack(element.tradeId)
return
}
});
// window.logBox.add(resp)
})
.catch((error) => console.error(error));
}
let wsOptions = {
isAdmin: true,
onReady: () => {
}
}
wsOptions.messageCallBack = (meg) => {
console.log(meg);
window.logBox.add(JSON.stringify(meg))
if (window.running) {
window.logBox.add(`购买:${meg.value.assetId} 价格-${meg.value.buyNowPrice}`)
searchItem(meg.value, (tradeId) => {
window.logBox.add(`成功:${meg.value.assetId} 价格-${meg.value.buyNowPrice}`)
fetch(`https://utas.mob.v5.prd.futc-ext.gcp.ea.com/ut/game/fc26/trade/${tradeId}/bid`, {
"headers": {
"accept": "*/*",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
"content-type": "application/json",
"x-ut-sid": window.activeID
},
"referrer": "https://www.ea.com/",
"body": JSON.stringify({"bid": meg.value.buyNowPrice}),
"method": "PUT",
"mode": "cors",
"credentials": "omit"
}).then((response) => response.text())
.then((result) => {
if (result.includes('auctionInfo')) {
return
}
window.logBox.add(result)
})
.catch((error) => console.error(error));
})
} else {
window.logBox.add('当前未开启自动下单!')
}
}
window.owoSocket = new owoSocket('eaGame', wsOptions)