preLoadFile.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. window.userSt = {}
  2. // 监听拦截到的数据
  3. window.onInterceptedData = function (data) {
  4. console.log(data)
  5. window.systemInfo = data
  6. switch (data.url) {
  7. case "https://utas.mob.v5.prd.futc-ext.gcp.ea.com/ut/auth":
  8. const result = JSON.parse(data.responseBody)
  9. if (result.sid) {
  10. window.activeID = result.sid
  11. if (window.logBox) window.logBox.add('获取到认证ID:' + window.activeID)
  12. }
  13. break;
  14. default:
  15. break;
  16. }
  17. if (data.url.includes('https://utas.mob.v5.prd.futc-ext.gcp.ea.com/ut/game/fc26/auctionhouse')) {
  18. console.log(data)
  19. const result2 = data.requestBody
  20. window.itemID = result2.itemData.id
  21. if (window.logBox) window.logBox.add(`卖出物品:${window.itemID}`)
  22. if (window.userSt[window.itemID]) {
  23. window.logBox.add(`获取到物品ID:${window.userSt[window.itemID].assetId}`)
  24. owoSocket.send("sell", {"id": window.itemID, "buyNowPrice": result2.buyNowPrice, "assetId": window.userSt[window.itemID].assetId})
  25. } else {
  26. window.logBox.add(`无法匹配物品:${window.itemID}`)
  27. }
  28. }
  29. if (data.url.includes('https://utas.mob.v5.prd.futc-ext.gcp.ea.com/ut/game/fc26/tradepile')) {
  30. const result3 = JSON.parse(data.responseBody)
  31. if (window.logBox) window.logBox.add(`获取到物品数量:${result3.auctionInfo.length}`)
  32. result3.auctionInfo.forEach(element => {
  33. window.userSt[element.itemData.id] = element.itemData
  34. });
  35. }
  36. if (data.url.includes('https://utas.mob.v5.prd.futc-ext.gcp.ea.com/ut/game/fc26/trade/') && data.url.includes('/bid')) {
  37. const result4 = JSON.parse(data.responseBody)
  38. if (window.logBox) window.logBox.add(`买入物品:${result4.auctionInfo[0].tradeId}`)
  39. window.userSt[result4.auctionInfo[0].itemData.id] = result4.auctionInfo[0].itemData
  40. }
  41. };
  42. let owoLoadList = []
  43. function loadCSS (url) {
  44. if (owoLoadList.includes(url)) {
  45. return
  46. }
  47. owoLoadList.push(url)
  48. var link = document.createElement("link");
  49. link.rel = "stylesheet";
  50. link.type = "text/css";
  51. link.href = url;
  52. document.getElementsByTagName("head")[0].appendChild(link);
  53. }
  54. setTimeout(() => {
  55. var box = document.getElementsByClassName('puge-box')
  56. if (!box[0]) {
  57. var insertElement = document.createElement("div");
  58. insertElement.style.display = 'none'
  59. insertElement.classList.add('puge-box')
  60. insertElement.style.zIndex = '9665'
  61. insertElement.style.width = '300px'
  62. insertElement.style.height = '560px'
  63. insertElement.style.position = 'fixed'
  64. insertElement.style.right = '0'
  65. insertElement.style.top = '0'
  66. insertElement.style.fontSize = '18px'
  67. insertElement.style.lineHeight = '30px'
  68. insertElement.style.padding = '10px'
  69. insertElement.style.backgroundColor = 'white'
  70. document.body.appendChild(insertElement);
  71. if (window.pugeCreated) {
  72. window.pugeCreated(insertElement)
  73. window.pugeCreated = null
  74. }
  75. }
  76. }, 1000)
  77. var box = document.getElementsByClassName('puge-menu')
  78. if (!box[0]) {
  79. var insertElement = document.createElement("div");
  80. insertElement.classList.add('puge-menu')
  81. insertElement.innerHTML = `
  82. <div class="puge" style="position: fixed;
  83. width: 40px;
  84. height: 40px;
  85. right: 10px;
  86. bottom: 120px;
  87. z-index: 9666;
  88. color: white;" onclick="owostart()"><svg t="1619252746615" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="19612" width="40" height="40"><path d="M622.7968 89.7024l60.1088 124.1088c15.9744 36.0448 52.0192 60.1088 92.16 66.048l134.144 20.0704c100.1472 14.0288 138.1376 136.192 68.096 208.2816l-98.0992 94.1056c-28.0576 28.0576-42.0864 68.096-36.0448 106.0864l22.016 134.144c15.9744 100.1472-86.1184 174.1824-176.2304 128.2048l-120.1152-62.0544c-36.0448-18.0224-76.0832-18.0224-112.128 0L334.4384 972.8c-90.112 46.08-192.2048-28.0576-176.2304-128.2048l22.016-134.144c7.9872-40.0384-6.0416-80.0768-36.0448-106.0864L46.08 508.2112c-72.0896-72.0896-32.0512-192.2048 68.096-208.2816l134.144-20.0704c40.0384-6.0416 74.1376-30.0032 92.16-66.048l60.1088-124.1088c50.0736-90.112 176.2304-90.112 222.208 0" fill="#FED44A" p-id="19613"></path><path d="M404.5824 89.7024l-60.1088 124.1088c-15.9744 36.0448-52.0192 60.1088-92.16 66.048l-134.144 20.0704c-62.0544 10.0352-102.0928 60.1088-104.1408 112.128 18.0224-98.0992 220.2624-22.016 312.4224-14.0288 94.1056 10.0352 120.1152-74.1376 120.1152-74.1376s20.0704-100.1472 44.032-226.304c18.0224-102.0928 86.1184-58.0608 110.1824-40.0384C544.768-0.4096 444.6208 11.6736 404.5824 89.7024" fill="#FFDE73" p-id="19614"></path><path d="M574.7712 784.5888c-74.1376-50.0736-140.1856 0-140.1856 0S362.496 848.6912 278.4256 928.768c-86.1184 80.0768-118.1696-33.9968-118.1696-33.9968 18.0224 72.0896 102.0928 116.1216 174.1824 76.0832l122.1632-62.0544c36.0448-18.0224 76.0832-18.0224 112.128 0L690.8928 972.8c56.1152 30.0032 118.1696 11.9808 152.1664-32.0512 2.048-7.9872 3.9936-14.0288 7.9872-20.0704-67.9936 66.1504-200.192-86.016-276.2752-136.0896" fill="#FEC54A" p-id="19615"></path><path d="M466.6368 103.7312c15.9744 3.9936 26.0096 18.0224 22.016 36.0448l-28.0576 126.1568c-3.9936 15.9744-18.0224 26.0096-36.0448 22.016-15.9744-3.9936-26.0096-18.0224-22.016-36.0448l28.0576-128.2048c3.9936-15.9744 20.0704-23.9616 36.0448-19.968" fill="#FFF2CA" p-id="19616"></path><path d="M375.3984 530.8416c-29.2864 0-53.0432-18.7392-53.0432-41.984 0-23.1424 23.7568-41.984 53.0432-41.984s53.0432 18.7392 53.0432 41.984c0 23.1424-23.7568 41.984-53.0432 41.984z m260.9152 0c-29.2864 0-53.0432-18.7392-53.0432-41.984 0-23.1424 23.7568-41.984 53.0432-41.984s53.0432 18.7392 53.0432 41.984c0 23.1424-23.7568 41.984-53.0432 41.984z m-190.464 74.6496c-2.56-3.6864-3.3792-8.192-2.56-12.4928 0.9216-4.3008 3.584-8.0896 7.2704-10.4448 7.8848-5.12 18.432-3.072 23.8592 4.608 12.288 17.7152 26.2144 25.8048 43.1104 25.8048s30.8224-8.0896 43.1104-25.8048c5.4272-7.68 15.9744-9.728 23.8592-4.608 3.7888 2.3552 6.4512 6.144 7.2704 10.4448 0.9216 4.3008 0 8.9088-2.56 12.4928-18.3296 26.5216-42.7008 40.6528-71.7824 40.6528-28.8768-0.1024-53.248-14.1312-71.5776-40.6528z m0 0" fill="#92410E" p-id="19617"></path></svg></div>
  89. `
  90. document.body.appendChild(insertElement);
  91. }
  92. function owostart () {
  93. const box = document.getElementsByClassName('puge-box')[0]
  94. // alert(box.style.display)
  95. if (box.style.display == 'none') {
  96. box.style.display = 'block'
  97. if (window.pugeCreated) {
  98. window.pugeCreated(document.getElementsByClassName('puge-box')[0])
  99. window.pugeCreated = null
  100. }
  101. } else {
  102. box.style.display = 'none'
  103. }
  104. window.loadingDialog = function () {
  105. return
  106. }
  107. }
  108. function logPanel (el, max) {
  109. if (el) {
  110. el.innerHTML = '<ul class="log-panel-w" style="height:300px;overflow: auto;"></ul>'
  111. setTimeout(() => {
  112. this.$el = el.querySelector('.log-panel-w')
  113. }, 0);
  114. }
  115. this.max = max || 100
  116. this.list = []
  117. this.add = function (text) {
  118. if (!text) text = ''
  119. var time = new Date();
  120. let hours = time.getHours()
  121. if (hours <= 9) hours = '0' + hours
  122. let minutes = time.getMinutes()
  123. if (minutes <= 9) minutes = '0' + minutes
  124. let seconds = time.getSeconds()
  125. if (seconds <= 9) seconds = '0' + seconds
  126. this.list.push([`${hours}:${minutes}:${seconds}`, text])
  127. if (this.list.length > this.max) {
  128. this.list = this.list.slice(1)
  129. }
  130. this.make()
  131. }
  132. this.make = function () {
  133. let newHtml = ''
  134. for (let index = this.list.length - 1; index >= 0; index--) {
  135. const element = this.list[index];
  136. newHtml += `<li><span>${element[0]}</span>${element[1]}</li>`
  137. }
  138. setTimeout(() => {
  139. this.$el.innerHTML = newHtml
  140. }, 0);
  141. }
  142. }
  143. setTimeout(() => {
  144. if (document.querySelector('.puge-box')) document.querySelector('.puge-box').innerHTML = `
  145. <div class="owo button" onclick="window.running=true;window.logBox.add('已开启下单');" style=" background-color: #009fe9; text-align: center; line-height: 40px; ">开始接收</div>
  146. <div class="owo button" onclick="window.running=false;window.logBox.add('已关闭下单');" style=" background-color: #009fe9; text-align: center; line-height: 40px; ">停止接收</div>
  147. <h5 style="color:black;">日志输出</h5>
  148. <div class="log-panel" style="height:300px;background-color: darkcyan;"></div>
  149. `
  150. setTimeout(() => {
  151. window.logBox = new logPanel(document.querySelector('.log-panel'))
  152. }, 0);
  153. }, 2000);
  154. function owoSocket(typeStr, options) {
  155. const that = this
  156. this.type = typeStr
  157. let timeConnect = 0;
  158. function reconnect(callBack) {
  159. timeConnect++;
  160. console.log("第" + timeConnect + "次重连");
  161. // 普通连接
  162. that.ws = new WebSocket('wss://ws.lamp.run')
  163. that.ws.addEventListener('open', function (event) {
  164. that.ws.send(JSON.stringify({"route": "login", "type": typeStr, "admin": options.isAdmin, "id": options.id}))
  165. if (callBack) callBack()
  166. if (options.onOpen) options.onOpen(that.ws)
  167. })
  168. that.ws.onerror = function () {
  169. console.error('服务器已经断开');
  170. // 进行重连
  171. setTimeout(function () {
  172. reconnect();
  173. }, 3000)
  174. };
  175. that.ws.addEventListener('message', function (event) {
  176. const mess = JSON.parse(event.data)
  177. if (mess.type === 'userInfo') {
  178. that.wsUserInfo = mess.value
  179. if (options.onReady) options.onReady(that.ws)
  180. } else {
  181. if (options.messageCallBack) options.messageCallBack(mess)
  182. }
  183. })
  184. }
  185. reconnect()
  186. this.send = function (route, value, sendTo) {
  187. // 先判断连接是否关闭 如果关闭先重新连接
  188. if (that.ws.readyState === 3) {
  189. console.error('ws连接已断开正在重连!')
  190. reconnect(()=> {
  191. that.ws.send(JSON.stringify({"route": route, "type": typeStr, "userID": that.wsUserInfo.userID, "id": sendTo, "value": value}))
  192. })
  193. } else {
  194. that.ws.send(JSON.stringify({"route": route, "type": typeStr, "userID": that.wsUserInfo.userID, "id": sendTo, "value": value}))
  195. }
  196. }
  197. }
  198. function searchItem(itemInfo, callBack) {
  199. // 查找ID
  200. window.logBox.add(`查找卡片:${itemInfo.assetId}`)
  201. // window.logBox.add(`开始购买:${JSON.stringify(playerInfo)}`)
  202. fetch(`https://utas.mob.v4.prd.futc-ext.gcp.ea.com/ut/game/fc26/transfermarket?num=21&start=0&type=player&maskedDefId=${itemInfo.assetId}&maxb=${itemInfo.buyNowPrice}`, {
  203. "headers": {
  204. "accept": "*/*",
  205. "accept-language": "zh-CN",
  206. "content-type": "application/json",
  207. "x-ut-sid": window.activeID
  208. },
  209. "referrer": "https://www.ea.com/",
  210. "body": null,
  211. "method": "GET",
  212. }).then((response) => response.json())
  213. .then((result) => {
  214. let resp = '搜索到列表:'
  215. result.auctionInfo.forEach(element => {
  216. resp += `[${element.itemData.id}]`
  217. if(element.itemData.id == itemInfo.id) {
  218. callBack(element.tradeId)
  219. return
  220. }
  221. });
  222. window.logBox.add(resp)
  223. })
  224. .catch((error) => console.error(error));
  225. }
  226. let wsOptions = {
  227. isAdmin: true,
  228. onReady: () => {
  229. }
  230. }
  231. wsOptions.messageCallBack = (meg) => {
  232. console.log(meg);
  233. window.logBox.add(JSON.stringify(meg))
  234. if (window.running) {
  235. searchItem(meg.value, (tradeId) => {
  236. window.logBox.add(`下单购买:${tradeId}`)
  237. fetch(`https://utas.mob.v5.prd.futc-ext.gcp.ea.com/ut/game/fc26/trade/${tradeId}/bid`, {
  238. "headers": {
  239. "accept": "*/*",
  240. "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,zh-TW;q=0.7",
  241. "content-type": "application/json",
  242. "x-ut-sid": window.activeID
  243. },
  244. "referrer": "https://www.ea.com/",
  245. "body": JSON.stringify({"bid": meg.value.buyNowPrice}),
  246. "method": "PUT",
  247. "mode": "cors",
  248. "credentials": "omit"
  249. }).then((response) => response.text())
  250. .then((result) => {
  251. if (result.includes('auctionInfo')) {
  252. window.logBox.add(`${meg.value.id}购买成功!`)
  253. return
  254. }
  255. window.logBox.add(result)
  256. })
  257. .catch((error) => console.error(error));
  258. })
  259. }
  260. }
  261. window.owoSocket = new owoSocket('eaGame', wsOptions)