饰品比例列表计算

饰品比例列表计算查看

  1. // ==UserScript==
  2. // @name 饰品比例列表计算
  3. // @namespace sourcewater
  4. // @version 0.1.23
  5. // @description 饰品比例列表计算查看
  6. // @author sourcewater
  7. // @match https://buff.163.com/market/?game=*
  8. // @match https://www.c5game.com/dota.html*
  9. // @match https://www.c5game.com/csgo/default/*
  10. // @match https://www.igxe.cn/dota2/*
  11. // @match https://www.igxe.cn/csgo/*
  12. // @grant GM_xmlhttpRequest
  13. // @connect www.c5game.com
  14. // @connect buff.163.com
  15. // @connect steamcommunity.com
  16. // @connect steamcommunity-a.akamaihd.net
  17. // ==/UserScript==
  18.  
  19. (function() {
  20.  
  21. let log={
  22. DEBUG:1,
  23. INFO:5,
  24. level:1,
  25. setLevel:function(level){
  26. this.level=level;
  27. },
  28. log:function(msg,level,prefix){
  29. let date=new Date();
  30. let time=date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
  31. if(level>=this.level){
  32. console.log(prefix+time+" >>>> "+msg);
  33. }
  34. },
  35. info:function (msg){
  36. this.log(msg,this.INFO,"info: ");
  37. },
  38. debug:function(msg){
  39. this.log(msg,this.DEBUG,"debug: ");
  40. }
  41. };
  42. log.setLevel(log.INFO);
  43. let priceCSSEle=document.createElement("style");
  44. priceCSSEle.setAttribute("type","text/css");
  45. const displaySuccessClass="s_s_s_s_display_success";
  46. const itemidAttr="s_s_s_s_item_id";
  47. const successAttr="s_s_s_s_success";
  48. const linkRegAttr="s_s_s_s_click_register";
  49. const contentChangeAttr="s_s_s_s_content_change";
  50. const progressDivId="s_s_s_s_progress_div";
  51. const progressDivAttr="s_s_s_s_progress_init_success";
  52. const waitingDivId="s_s_s_s_waiting_div";
  53. const appidList={"csgo":730,"dota2":570};
  54. const buffUrlReg=/buff\.163\.com\//;
  55. const c5UrlReg=/c5game\.com\//;
  56. const igxeUrlReg=/igxe\.cn/;
  57. const timeout=6000;
  58. let index=0;
  59. let progressDivEle=document.createElement("div");
  60. progressDivEle.setAttribute("id",progressDivId);
  61. progressDivEle.setAttribute("style","z-index: 999;border-radius:4px; border: 4px solid white; text-align: center;position: absolute;left: 50%;top: 55%;transform: translate(-50%, -50%);background:white;padding:5px;");
  62. progressDivEle.innerHTML=`
  63. <p>
  64. <strong style="color:black;">正在初始化</strong><br>
  65. <progress style="width:200px;height:25px;"></progress>
  66. </p>
  67. `;
  68. document.body.appendChild(progressDivEle);
  69. let priceCSS=`
  70. .s_s_s_s_display_success{
  71. display:block;
  72. }
  73. .s_s_s_s_cell_right,
  74. .s_s_s_s_cell_link,
  75. .s_s_s_s_cell_after_fee,
  76. .s_s_s_s_cell_rate,
  77. .s_s_s_s_cell_rate_high{
  78. width:50px;
  79. text-align:right;
  80. }
  81. .s_s_s_s_cell_left{
  82. display:inline-block;
  83. width:50px;
  84. text-align:left;
  85. }
  86. .s_s_s_s_cell_right{
  87. color:#eea20e;
  88. }
  89. .s_s_s_s_cell_link{
  90. color:black;
  91. }
  92. .s_s_s_s_cell_rate{
  93. color:green;
  94. }
  95. .s_s_s_s_cell_rate_high{
  96. color:red;
  97. }
  98. `;
  99. let customPriceCss;
  100. if(buffUrlReg.test(window.location.href)){
  101. customPriceCss=`
  102. .s_s_s_s_cell_left{
  103. color:black;
  104. }
  105. .s_s_s_s_display_success{
  106. margin-left:15px;
  107. height:167px;
  108. }
  109. .s_s_s_s_cell_after_fee{
  110. color:purple;
  111. }
  112. `;
  113. /*
  114. let enLocale="Locale-Supported=en;";
  115. if(document.cookie.lastIndexOf(enLocale)<0){
  116. document.cookie=enLocale+"path=/";
  117. window.location.reload();
  118. }
  119. */
  120. }else if(c5UrlReg.test(window.location.href)){
  121. customPriceCss=`
  122. .s_s_s_s_cell_left{
  123. color:white;
  124. }
  125. .s_s_s_s_display_success{
  126. margin-left:15px;
  127. height:205px;
  128. }
  129. .s_s_s_s_cell_after_fee{
  130. color:#55aa88;
  131. }
  132. `;
  133. }else if(igxeUrlReg.test(window.location.href)){
  134. customPriceCss=`
  135. .s_s_s_s_cell_left{
  136. color:white;
  137. }
  138. .s_s_s_s_display_success{
  139. margin-left:15px;
  140. height:205px;
  141. }
  142. .s_s_s_s_cell_after_fee{
  143. color:#55aa88;
  144. }
  145. `;
  146. }
  147. priceCSSEle.innerHTML=priceCSS+customPriceCss;
  148. document.head.appendChild(priceCSSEle);
  149. function checkInitCalculate(){
  150. if(!progressDivEle.getAttribute(progressDivAttr)){
  151. initCalculate();
  152. return;
  153. }
  154. log.info("init successfully!");
  155. }
  156. function initCalculate(){
  157. setTimeout(function(){checkInitCalculate();},timeout);
  158. let steamMarketUrl="https://steamcommunity.com/market/";
  159. let walletVariable="var g_rgWalletInfo = ";
  160. GM_xmlhttpRequest({
  161. url: steamMarketUrl,
  162. method: 'GET',
  163. //timeout:10000,
  164. onload: function(res){
  165. if(res.status === 200){
  166. let html=res.responseText;
  167. walletVariable+=html.match(/var g_rgWalletInfo(.|\n)*?(\{+?(.|\n)*?\}+?)+/)[2];
  168. let varScriptEle=document.createElement("script");
  169. varScriptEle.setAttribute("type","text/javascript");
  170. varScriptEle.innerHTML=walletVariable;
  171. document.body.appendChild(varScriptEle);
  172. let calculateJSUrl="https://steamcommunity-a.akamaihd.net/public/javascript/economy_common.js?v=tsXdRVB0yEaR&l=schinese&_cdn=china_pinyuncloud";
  173. GM_xmlhttpRequest({
  174. url: calculateJSUrl,
  175. method: 'GET',
  176. //timeout:10000,
  177. onload: function(res){
  178. if(res.status === 200){
  179. let calculateScript=res.responseText;
  180. let calScriptEle=document.createElement("script");
  181. calScriptEle.setAttribute("type","text/javascript");
  182. calScriptEle.innerHTML=calculateScript;
  183. document.head.appendChild(calScriptEle);
  184. progressDivEle.setAttribute(progressDivAttr,"success");
  185. start(window.location.href);
  186. document.body.removeChild(progressDivEle);
  187. }else{
  188. log.info("initCalculate(): 访问Steam市场错误!");
  189. }
  190. },onerror : function(err){
  191. log.info("initCalculate(): 访问Steam市场超时!");
  192. },ontimeout : function(err){
  193. log.info("initCalculate(): 访问超时");
  194. }
  195. });
  196. }else{
  197. log.info("initCalculate(): 访问Steam市场错误!");
  198. }
  199. },onerror : function(err){
  200. log.info("initCalculate(): 访问Steam市场超时!");
  201. },ontimeout : function(err){
  202. log.info("initCalculate(): 访问超时");
  203. }
  204. });
  205.  
  206. }
  207. initCalculate();
  208. function getPriceValueAsInt(value){
  209. if(!isNaN(value)){
  210. value=value.toString();
  211. if(value.lastIndexOf(".")<0){
  212. value=value+"00";
  213. }else if(value.length-value.lastIndexOf(".") == 2){
  214. value+="0";
  215. }
  216. }
  217. return parseInt(value.replace(".",""));
  218. }
  219. function receivePrice(price){
  220. if(typeof price != 'undefined'){
  221. return (getPriceValueAsInt(price)-parseInt(CalculateFeeAmount(getPriceValueAsInt(price),g_rgWalletInfo["wallet_publisher_fee_percent_default"]).fees))/100;
  222. }
  223. return 0;
  224. }
  225. function queryPrice(currentIndex,appid,name,updateView,args){
  226. log.info("new task index: "+currentIndex);
  227. if(currentIndex<index){
  228. log.debug("stop previous check update for index: "+currentIndex);
  229. return;
  230. }
  231. function checkUpdate(currentIndex,item_nameid,steamUrl,element){
  232. if(currentIndex<index){
  233. log.debug("stop previous check update for index: "+currentIndex);
  234. return;
  235. }
  236. if(!args.element.getAttribute(successAttr)){
  237. update(item_nameid,steamUrl);
  238. log.debug("retry get price >>>> "+item_nameid);
  239. }
  240. log.debug(item_nameid+" >>>> get price finish!");
  241. }
  242. function update(item_nameid,steamUrl){
  243. if(currentIndex<index){
  244. log.debug("stop previous check update for index: "+currentIndex);
  245. return;
  246. }
  247. let buyPrice=-1;
  248. let sellPrice=-1;
  249. setTimeout(function(){checkUpdate(currentIndex,item_nameid,steamUrl,args.element);},timeout);
  250. log.debug(`update: "https://steamcommunity.com/market/itemordershistogram?country=CN&language=schinese&currency=23&item_nameid=${item_nameid}&two_factor=0"`);
  251. GM_xmlhttpRequest({
  252. url: `https://steamcommunity.com/market/itemordershistogram?country=CN&language=schinese&currency=23&item_nameid=${item_nameid}&two_factor=0`,
  253. method: 'GET',
  254. //timeout:10000,
  255. responseType: 'json',
  256. onload: function(res){
  257. if(res.status === 200){
  258. let data=res.response;
  259. if(data.success==1){
  260. if(data.buy_order_graph.length>0&&data.buy_order_graph[0].length>0){
  261. buyPrice=data.buy_order_graph[0][0];
  262. }
  263. if(data.sell_order_graph.length>0&&data.sell_order_graph[0].length>0){
  264. sellPrice=data.sell_order_graph[0][0];
  265. }
  266. args.sellPrice=sellPrice;
  267. args.buyPrice=buyPrice;
  268. args.steamUrl=steamUrl;
  269. updateView(args);
  270. }
  271. }else{
  272. log.info("update(): "+res.status+" :访问Steam市场错误!");
  273. }
  274. },onerror : function(err){
  275. log.info("update(): 访问Steam市场超时!");
  276. },ontimeout : function(err){
  277. log.info("update(): 访问超时");
  278. }
  279. });
  280. }
  281. function checkFetchInfo(currentIndex,item_nameid){
  282. if(currentIndex<index){
  283. log.debug("stop previous check fetch info for index: "+currentIndex);
  284. return;
  285. }
  286. if(!args.element.getAttribute(itemidAttr)){
  287. fetchInfo();
  288. log.debug("retry get item name id.");
  289. }
  290. log.debug(item_nameid+" >>>> get item name id finish!");
  291. }
  292. function fetchInfo(){
  293. let item_nameid="";
  294. if(currentIndex<index){
  295. log.debug("stop previous check update for index: "+currentIndex);
  296. return;
  297. }
  298. let steamUrl=`https://steamcommunity.com/market/listings/${appid}/${name}`;
  299. setTimeout(function(){checkFetchInfo(currentIndex,item_nameid);},timeout);
  300. GM_xmlhttpRequest({
  301. method: "get",
  302. url: steamUrl,
  303. //timeout:10000,
  304. async: false,
  305. onload: function(res){
  306. if(res.status === 200){
  307. let response=res.responseText;
  308. let nameidMatchs=response.match(/Market_LoadOrderSpread\(.*?([\d]+).*?\);/);
  309. log.debug("<nameidMatchs: "+nameidMatchs+">");
  310. if(nameidMatchs){
  311. item_nameid=nameidMatchs.length == 2 ? nameidMatchs[1] : "";
  312. log.debug("<item_nameid: "+item_nameid+">");
  313. if(item_nameid!=""){
  314. args.element.setAttribute(itemidAttr,"success");
  315. update(item_nameid,steamUrl);
  316. }
  317. }else{
  318. args.element.querySelector("#"+waitingDivId).innerHTML=`<span style="color: red;display:block;text-align: center;position: relative;left: 50%;top: 50%;transform: translate(-50%, -50%);">此物品不在货架上。</span>`;
  319. args.element.querySelector("#"+waitingDivId).setAttribute("class",displaySuccessClass);
  320. args.element.setAttribute(itemidAttr,"success");
  321. args.element.setAttribute(successAttr,"true");
  322. }
  323. }else{
  324. log.info("fetchInfo(): Error Code: "+res.status);
  325. }
  326. },onerror : function(err){
  327. log.info("fetchInfo(): 访问Steam市场错误!");
  328. },ontimeout : function(err){
  329. log.info("fetchInfo(): 访问超时");
  330. }
  331. });
  332. }
  333. fetchInfo();
  334. }
  335. function updateView(args){
  336. let purchasePrice,sellRate,buyRate;
  337. let priceSpan=document.createElement("span");
  338. let success=true;
  339. if(buffUrlReg.test(args.url)&&!args.element.getAttribute(successAttr)){
  340. purchasePrice=parseFloat(args.element.querySelector("strong.f_Strong").innerHTML.match(/[\d\.]/g).join(""));
  341. }else if(c5UrlReg.test(args.url)&&!args.element.getAttribute(successAttr)){
  342. purchasePrice=parseFloat(args.element.querySelector("span.price").innerHTML.match(/[\d\.]/g).join(""));
  343. }else if(igxeUrlReg.test(args.url)&&!args.element.getAttribute(successAttr)){
  344. purchasePrice=parseFloat(args.element.querySelector(".price.fl").textContent.match(/[\d\.]+/g).join(""));
  345. }else{
  346. success=false;
  347. }
  348. if(success){
  349. sellRate=(purchasePrice/receivePrice(args.sellPrice)).toFixed(2);
  350. buyRate=(purchasePrice/receivePrice(args.buyPrice)).toFixed(2);
  351. args.element.removeChild(args.element.querySelector("#"+waitingDivId));
  352. priceSpan.setAttribute("class",displaySuccessClass);
  353. let priceContent=`
  354. <br><span class="s_s_s_s_cell_left">卖出:</span><span class="s_s_s_s_cell_right">${(args.sellPrice == -1 ? "无" : args.sellPrice)}</span>
  355. <br><span class="s_s_s_s_cell_left">税后:</span><span class="s_s_s_s_cell_after_fee">${args.sellPrice == -1 ? "无" : receivePrice(args.sellPrice)}</span>
  356. <br><span class="s_s_s_s_cell_left">比例:</span><span class="${ sellRate > 0.7 ? "s_s_s_s_cell_rate_high": "s_s_s_s_cell_rate"}">${args.sellPrice == -1 ? "无" : sellRate}</span>
  357. <br><br><span class="s_s_s_s_cell_left">买入:</span><span class="s_s_s_s_cell_right">${(args.buyPrice == -1 ? "无" : args.buyPrice)}</span>
  358. <br><span class="s_s_s_s_cell_left">税后:</span><span class="s_s_s_s_cell_after_fee">${args.buyPrice == -1 ? "无" : receivePrice(args.buyPrice)}</span>
  359. <br><span class="s_s_s_s_cell_left">比例:</span><span class="${ buyRate > 0.9 ? "s_s_s_s_cell_rate_high": "s_s_s_s_cell_rate"}">${args.buyPrice == -1 ? "无" : buyRate}</span>
  360. <br><br>
  361. <span class="s_s_s_s_cell_link"><a href="${args.steamUrl}" target="_blank">Steam链接</a></span>
  362. `;
  363. priceSpan.innerHTML=priceContent;
  364. args.element.setAttribute(successAttr,"true");
  365. args.element.appendChild(priceSpan);
  366. log.debug("update view successfully!");
  367. }
  368. }
  369. function waitForElement(selector,task){
  370. if(document.querySelector(selector)){
  371. task();
  372. }else{
  373. setTimeout(function(){waitForElement(selector,task);},100);
  374. }
  375. }
  376. let missionStart=false;
  377. function start(url){
  378. let cards;
  379. let cardClass;
  380. let appid;
  381. if(buffUrlReg.test(url)){
  382. let buffCSGOReg=/game=csgo/;
  383. let buffDotaReg=/game=dota2/;
  384. if(buffCSGOReg.test(url)){
  385. cardClass=".card_csgo";
  386. appid=appidList.csgo;
  387. }else if(buffDotaReg.test(url)){
  388. cardClass=".card_dota2";
  389. appid=appidList.dota2;
  390. }
  391. waitForElement(cardClass,function(){
  392. cards=document.querySelector(cardClass).querySelectorAll("li");
  393. startQuery();
  394. });
  395.  
  396. }else if(c5UrlReg.test(url)){
  397. let c5CSGOReg=/\/csgo\//;
  398. let c5DotaReg=/dota\.html/;
  399. cardClass=".list-item4";
  400. if(c5DotaReg.test(url)){
  401. appid=appidList.dota2;
  402. }else if(c5CSGOReg.test(url)){
  403. appid=appidList.csgo;
  404. }
  405. waitForElement(cardClass,function(){
  406. cards=document.querySelector(cardClass).querySelectorAll("li");
  407. startQuery();
  408. });
  409. }else if(igxeUrlReg.test(url)){
  410. let igxeCSGOReg=/\/csgo\//;
  411. let igxeDotaReg=/\/dota2\//;
  412. cardClass=".dataList";
  413. if(igxeDotaReg.test(url)){
  414. appid=appidList.dota2;
  415. }else if(igxeCSGOReg.test(url)){
  416. appid=appidList.csgo;
  417. }
  418. waitForElement(cardClass,function(){
  419. cards=document.querySelector(cardClass).querySelectorAll("a");
  420. startQuery();
  421. });
  422. }
  423. function startQuery(){
  424. ++index;
  425. if(buffUrlReg.test(url)){
  426. for(let i=0;i<cards.length;++i){
  427. let card=cards[i];
  428. let currentIndex=index;
  429. let progressEleDiv=document.createElement("div");
  430. progressEleDiv.setAttribute("id",waitingDivId);
  431. card.setAttribute("style","height:399px!important;");
  432. progressEleDiv.setAttribute("style","width:208px;height:120px;");
  433. progressEleDiv.innerHTML=`<progress style="text-align: center;position: relative;left: 50%;top: 50%;transform: translate(-50%, -50%);"></progress>`;
  434. let buffItemEnNameAttr="s_s_s_s_buff_item_en_name_attr";
  435. let decodeTextEle=document.createElement("textarea");
  436. card.appendChild(progressEleDiv);
  437. function checkItemEnName(card,currentIndex){
  438. if(!card.getAttribute(buffItemEnNameAttr)){
  439. getItemEnName(card,currentIndex);
  440. log.debug("Buff: retry get the en name!");
  441. }
  442. log.debug("Buff: got the en name!");
  443. }
  444. function getItemEnName(card,currentIndex){
  445. setTimeout(function(){checkItemEnName(card,currentIndex);},5000);
  446. GM_xmlhttpRequest({
  447. url: `${card.querySelector("a").href}`,
  448. method: 'GET',
  449. //timeout:10000,
  450. onload: function(res){
  451. if(res.status === 200){
  452. let html=res.responseText;
  453. let steamLinkReg=/"https:\/\/steamcommunity.com\/market\/listings\/(.*?)"/;
  454. let steamLink=html.match(/"https:\/\/steamcommunity.com\/market\/listings\/(.*?)"/);
  455. if(steamLink.length>0){
  456. decodeTextEle.innerHTML=steamLink[1].substring(steamLink[1].lastIndexOf("\/")+1);
  457. let enName=decodeTextEle.value;
  458. queryPrice(currentIndex,appid,enName,updateView,{"url":url,"element":card});
  459. card.setAttribute(buffItemEnNameAttr,"success");
  460. }
  461. }else{
  462. log.info("访问Buff页面错误: error code: "+res.status);
  463. }
  464. },onerror : function(err){
  465. log.info("访问Buff页面错误!");
  466. },ontimeout : function(err){
  467. log.info("访问Buff页面超时!");
  468. }
  469. });
  470. }
  471. getItemEnName(card,currentIndex);
  472. }
  473. let marketCard=document.querySelector("#j_market_card");
  474. if(!missionStart){
  475. let marketCardConfig = { childList: true };
  476. let observer = new MutationObserver(function(){
  477. if(!document.querySelector(cardClass)){
  478. if(!marketCard.getAttribute(contentChangeAttr)){
  479. marketCard.setAttribute(contentChangeAttr,"true");
  480. }
  481. }
  482. });
  483. observer.observe(marketCard, marketCardConfig);
  484. let marketCardConfigAttr={ attributes: true };
  485. let observerAttr = new MutationObserver(function(){
  486. if(marketCard.getAttribute(contentChangeAttr)){
  487. marketCard.removeAttribute(contentChangeAttr);
  488. start(window.location.href);
  489. }
  490. });
  491. observerAttr.observe(marketCard, marketCardConfigAttr);
  492. missionStart=true;
  493. }
  494. }
  495. else if(c5UrlReg.test(url)){
  496. let c5ItemEnNameAttr="s_s_s_s_c5_item_en_name_attr";
  497. let decodeTextEle=document.createElement("textarea");
  498. function runPart(start,end){
  499. for(let i=start;i<end;++i){
  500. let currentIndex=index;
  501. let card=cards[i];
  502. let progressEleSpan=document.createElement("span");
  503. progressEleSpan.setAttribute("style","height:205px;display:block;");
  504. progressEleSpan.setAttribute("id",waitingDivId);
  505. progressEleSpan.innerHTML=`<progress style="text-align: center;position: relative;left: 50%;top: 50%;transform: translate(-50%, -50%);"></progress>`;
  506. card.appendChild(progressEleSpan);
  507. function checkItemEnName(card,currentIndex){
  508. if(!card.getAttribute(c5ItemEnNameAttr)){
  509. getItemEnName(card,currentIndex);
  510. log.debug("c5: retry get the en name!");
  511. }
  512. log.debug("c5: got the en name!");
  513. }
  514. function getItemEnName(card,currentIndex){
  515. setTimeout(function(){checkItemEnName(card,currentIndex);},5000);
  516. GM_xmlhttpRequest({
  517. url: `${card.querySelector("a").href}`,
  518. method: 'GET',
  519. //timeout:10000,
  520. onload: function(res){
  521. if(res.status === 200){
  522. let html=res.responseText;
  523. let steamLinkReg=/"https:\/\/steamcommunity.com\/market\/listings\/(.*?)"/;
  524. let steamLink=html.match(/"https:\/\/steamcommunity.com\/market\/listings\/(.*?)"/);
  525. if(steamLink.length>0){
  526. decodeTextEle.innerHTML=steamLink[1].substring(steamLink[1].lastIndexOf("\/")+1);
  527. let enName=decodeTextEle.value;
  528. queryPrice(currentIndex,appid,enName,updateView,{"url":url,"element":card});
  529. card.setAttribute(c5ItemEnNameAttr,"success");
  530. }
  531. }else{
  532. log.info("访问C5页面错误: error code: "+res.status);
  533. }
  534. },onerror : function(err){
  535. log.info("访问C5页面错误!");
  536. },ontimeout : function(err){
  537. log.info("访问C5页面超时!");
  538. }
  539. });
  540. }
  541. getItemEnName(card,currentIndex);
  542. }
  543. }
  544. let half=cards.length>32 ? parseInt(cards.length/2) : cards.length;
  545. if(half!=0&&half<cards.length){
  546. let intervalId=setInterval(function(){
  547. let count=document.querySelectorAll("."+displaySuccessClass).length;
  548. if(count==half){
  549. clearInterval(intervalId);
  550. log.info("run part 2!");
  551. let part2notifyId="s_s_s_s_c5_part2_notify";
  552. let width=200;
  553. let height=25;
  554. let left=document.documentElement.scrollLeft + (document.documentElement.clientWidth - width) / 2;
  555. let top=document.documentElement.scrollTop + (document.documentElement.clientHeight - height) / 2;
  556. let notifyEle=document.createElement("div");
  557. notifyEle.setAttribute("id",part2notifyId);
  558. notifyEle.setAttribute("style","z-index: 999;border-radius:4px; border: 4px solid white; text-align: center;position: absolute;left: "+left+"px;top: "+top+"px;transform: translate(-50%, -50%);background:white;padding:5px;");
  559. notifyEle.innerHTML=`
  560. <strong style="color:black;">请等待10秒后加载第二部分!</strong><br>
  561. <progress style="width:${width}px;height:${height}px;"></progress>
  562. `;
  563. document.body.appendChild(notifyEle);
  564. setTimeout(function(){
  565. document.body.removeChild(document.querySelector("#"+part2notifyId));
  566. runPart(half,cards.length);
  567. },10000);
  568. }
  569. },1000);
  570. }
  571. log.info("run part 1!");
  572. runPart(0,half);
  573. }
  574. else if(igxeUrlReg.test(url)||c5UrlReg.test(url)){
  575. const itemEnNameAttr="s_s_s_s_item_enName_success";
  576. function checkGetEnNameAndQuery(appid,cnName,progressEleSpan,card){
  577. if(!card.getAttribute(itemEnNameAttr)){
  578. getEnNameAndQuery(appid,cnName,progressEleSpan,card);
  579. log.debug("retry get en name");
  580. }
  581. log.debug("get en name for "+cnName+" successfully!");
  582. }
  583. function getEnNameAndQuery(appid,cnName,progressEleSpan,card){
  584. setTimeout(function(){checkGetEnNameAndQuery(appid,cnName,progressEleSpan,card);},timeout);
  585. GM_xmlhttpRequest({
  586. //url: `https://steamcommunity.com/market/search?appid=${appid}&q=${cnName}`,
  587. url: `https://steamcommunity.com/market/search/render/?query=${cnName}&start=0&count=1&appid=${appid}&norender=1`,
  588. method: 'GET',
  589. responseType: 'json',
  590. onload: function(res){
  591. if(res.status === 200){
  592. let data=res.response;
  593. let linkList=data.results;
  594. let enName="";
  595. if(linkList&&linkList.length>0){
  596. for(let i=0;i<linkList.length;++i){
  597. let matchCNName=linkList[i].name;
  598. if(matchCNName==cnName){
  599. enName=linkList[i].hash_name;
  600. }
  601. }
  602. if(enName!=""){
  603. queryPrice(index,appid,enName,updateView,{"url":url,"element":card});
  604. }else{
  605. progressEleSpan.innerHTML=`<span style="color: red;display:block;text-align: center;position: relative;left: 50%;top: 50%;transform: translate(-50%, -50%);">此物品不在货架上。</span>`;
  606. progressEleSpan.setAttribute("class",displaySuccessClass);
  607. card.setAttribute(itemidAttr,"success");
  608. }
  609. card.setAttribute(itemEnNameAttr,"success");
  610. }
  611. }else{
  612. log.info("startQuery(): 访问Steam市场错误!Code: "+res.status);
  613. }
  614. },onerror : function(err){
  615. log.info("startQuery(): 访问Steam市场错误!");
  616. },ontimeout : function(err){
  617. log.info("startQuery(): 访问超时");
  618. }
  619. });
  620. }
  621. for(let i=0;i<cards.length;++i){
  622. let progressEleSpan=document.createElement("span");
  623. progressEleSpan.setAttribute("style","height:205px;display:block;");
  624. progressEleSpan.setAttribute("id",waitingDivId);
  625. let card=cards[i];
  626. let cnName=card.querySelector(".name").title;
  627. card.setAttribute("style","height: 450px;");
  628. progressEleSpan.innerHTML=`<progress style="text-align: center;position: relative;left: 50%;top: 50%;transform: translate(-50%, -50%);"></progress>`;
  629. card.appendChild(progressEleSpan);
  630. getEnNameAndQuery(appid,cnName,progressEleSpan,card);
  631. }
  632. }
  633. }
  634. }
  635. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址