naraka_score.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. const baseParse = _ => {
  2. const role_path = "hiker://files/rules/js/TyrantGenesis_永劫无间用户绑定.js"
  3. let d = [];
  4. let roleId = ''
  5. let empty = 'hiker://empty'
  6. let current_page = MY_URL.split('##')[1].toString()
  7. let cate_select = getVar("tyrantgenesis.naraka_score.cate_select", "1")
  8. let game_mode = getVar("tyrantgenesis.naraka_score.game_mode", "1")
  9. if (current_page === '1') {
  10. d.push({
  11. title: '添加',
  12. desc: '请输入游戏昵称',
  13. url: "input.trim() ? $('hiker://empty').lazyRule(params => {eval(fetch('hiker://files/TyrantG/TOOL/naraka_score.js'));return setRoleId(params);}, {input: input.trim()}) : 'toast://请输入游戏昵称''",
  14. col_type: "input"
  15. })
  16. d.push({
  17. title: cate_select === '1' ? '‘‘’’<strong><font color="red">最近战绩</font></strong>' : '最近战绩',
  18. url: $(empty).lazyRule(_ => {
  19. putVar("tyrantgenesis.naraka_score.cate_select", "1")
  20. refreshPage(true)
  21. return "hiker://empty"
  22. }),
  23. col_type: 'scroll_button',
  24. })
  25. d.push({
  26. title: cate_select === '2' ? '‘‘’’<strong><font color="red">生涯数据</font></strong>' : '生涯数据',
  27. url: $(empty).lazyRule(_ => {
  28. putVar("tyrantgenesis.naraka_score.cate_select", "2")
  29. refreshPage(true)
  30. return "hiker://empty"
  31. }),
  32. col_type: 'scroll_button',
  33. })
  34. d.push({
  35. title: cate_select === '3' ? '‘‘’’<strong><font color="red">角色数据</font></strong>' : '角色数据',
  36. url: $(empty).lazyRule(_ => {
  37. putVar("tyrantgenesis.naraka_score.cate_select", "3")
  38. refreshPage(true)
  39. return "hiker://empty"
  40. }),
  41. col_type: 'scroll_button',
  42. })
  43. /*d.push({
  44. title: cate_select === '4' ? '‘‘’’<strong><font color="red">武器数据</font></strong>' : '武器数据',
  45. url: $(empty).lazyRule(_ => {
  46. putVar("tyrantgenesis.naraka_score.cate_select", "4")
  47. refreshPage(true)
  48. return "hiker://empty"
  49. }),
  50. col_type: 'scroll_button',
  51. })*/
  52. // d.push({
  53. // title: cate_select === '5' ? '‘‘’’<strong><font color="red">地图模拟器</font></strong>' : '地图模拟器',
  54. // url: $(empty).lazyRule(_ => {
  55. // putVar("tyrantgenesis.naraka_score.cate_select", "5")
  56. // refreshPage(true)
  57. // return "hiker://empty"
  58. // }),
  59. // col_type: 'scroll_button',
  60. // })
  61. }
  62. if (fetch(role_path)) {
  63. roleId = fetch(role_path)
  64. if (cate_select === '1') {
  65. let listData = "https://gamedb.gamersky.com/yjwujian/record/getRecentRecords?roleId="+roleId+"&pageIndex="+current_page+"&pageSize=20"
  66. let res_json = fetch(listData)
  67. let res = JSON.parse(res_json)
  68. if (res.code === 0) {
  69. res.data.list.forEach(item => {
  70. d.push({
  71. title: "‘‘’’<strong>#&nbsp;<font color=\"red\">"+item.rank+"</font></strong>",
  72. url: "hiker://empty",
  73. col_type: 'text_4',
  74. })
  75. d.push({
  76. title: item.battleMode,
  77. pic_url: "https:"+item.battleModeImage+"@Referer=https://www.gamersky.com/",
  78. url: "hiker://empty",
  79. col_type: 'icon_4',
  80. })
  81. d.push({
  82. title: item.hero,
  83. pic_url: "https:"+item.heroImage+"@Referer=https://www.gamersky.com/",
  84. url: "hiker://empty",
  85. col_type: 'icon_4',
  86. })
  87. d.push({
  88. title: item.grade,
  89. pic_url: "https:"+item.gradeImageUrl+"@Referer=https://www.gamersky.com/",
  90. url: "hiker://empty",
  91. col_type: 'icon_4',
  92. })
  93. d.push({
  94. title: "‘‘’’<strong>分数:&nbsp;<font color=\"red\">"+item.gradeScore+"</font></strong>",
  95. url: "hiker://empty",
  96. col_type: 'text_2',
  97. })
  98. d.push({
  99. title: "‘‘’’<strong>击杀:&nbsp;<font color=\"red\">"+item.killTimes+"</font></strong>",
  100. url: "hiker://empty",
  101. col_type: 'text_2',
  102. })
  103. d.push({
  104. title: "‘‘’’<strong>伤害:&nbsp;<font color=\"red\">"+item.damage+"</font></strong>",
  105. url: "hiker://empty",
  106. col_type: 'text_2',
  107. })
  108. d.push({
  109. title: "‘‘’’<strong>评分:&nbsp;<font color=\"red\">"+item.performScore+"</font></strong>",
  110. url: "hiker://empty",
  111. col_type: 'text_2',
  112. })
  113. d.push({
  114. col_type: 'line_blank'
  115. })
  116. })
  117. } else {
  118. d.push({
  119. title: res.message,
  120. col_type: 'long_text',
  121. })
  122. }
  123. } else if (cate_select === '2') {
  124. if (current_page === '1') {
  125. d.push({
  126. col_type: 'blank_block',
  127. })
  128. d.push({
  129. title: game_mode === '1' ? '‘‘’’<strong><font color="red">单人</font></strong>' : '单人',
  130. url: $(empty).lazyRule(_ => {
  131. putVar("tyrantgenesis.naraka_score.game_mode", "1")
  132. refreshPage(true)
  133. return "hiker://empty"
  134. }),
  135. col_type: 'scroll_button',
  136. })
  137. d.push({
  138. title: game_mode === '2' ? '‘‘’’<strong><font color="red">三人</font></strong>' : '三人',
  139. url: $(empty).lazyRule(_ => {
  140. putVar("tyrantgenesis.naraka_score.game_mode", "2")
  141. refreshPage(true)
  142. return "hiker://empty"
  143. }),
  144. col_type: 'scroll_button',
  145. })
  146. d.push({
  147. title: game_mode === '3' ? '‘‘’’<strong><font color="red">死斗</font></strong>' : '死斗',
  148. url: $(empty).lazyRule(_ => {
  149. putVar("tyrantgenesis.naraka_score.game_mode", "3")
  150. refreshPage(true)
  151. return "hiker://empty"
  152. }),
  153. col_type: 'scroll_button',
  154. })
  155. let url = "https://gamedb.gamersky.com/yjwujian/career/getCareerData?gamerskyId=5861820&identity=0&roleId=" + roleId
  156. let res_json = fetch(url)
  157. let res = JSON.parse(res_json)
  158. let data = {}
  159. if (res.code === 0) {
  160. if (game_mode === '1') {
  161. data = res.data.single
  162. } else if (game_mode === '2') {
  163. data = res.data.three
  164. } else if (game_mode === '3') {
  165. data = res.data.chaos
  166. }
  167. d.push({
  168. title: "场次:" + data.gameCount,
  169. url: "hiker://empty",
  170. col_type: 'text_2',
  171. })
  172. d.push({
  173. title: "场均击杀:" + data.avgKillTimes,
  174. url: "hiker://empty",
  175. col_type: 'text_2',
  176. })
  177. d.push({
  178. title: "场均伤害:" + data.avgDamage,
  179. url: "hiker://empty",
  180. col_type: 'text_2',
  181. })
  182. d.push({
  183. title: "KD:" + data.kd,
  184. url: "hiker://empty",
  185. col_type: 'text_2',
  186. })
  187. d.push({
  188. col_type: 'line_blank'
  189. })
  190. d.push({
  191. title: "总伤害:" + data.sumDamage,
  192. url: "hiker://empty",
  193. col_type: 'text_2',
  194. })
  195. d.push({
  196. title: "总击杀:" + data.sumKillTimes,
  197. url: "hiker://empty",
  198. col_type: 'text_2',
  199. })
  200. d.push({
  201. title: "总死亡:" + data.sumDeadTimes,
  202. url: "hiker://empty",
  203. col_type: 'text_2',
  204. })
  205. d.push({
  206. title: "总救援:" + data.sumRescueTimes,
  207. url: "hiker://empty",
  208. col_type: 'text_2',
  209. })
  210. /*d.push({
  211. title: "总振刀:" + data.sumShockCount,
  212. url: "hiker://empty",
  213. col_type: 'text_2',
  214. })*/
  215. d.push({
  216. title: "总治疗:" + data.sumCure,
  217. url: "hiker://empty",
  218. col_type: 'text_2',
  219. })
  220. d.push({
  221. col_type: 'line_blank'
  222. })
  223. d.push({
  224. title: "最高伤害:" + data.maxDamage,
  225. url: "hiker://empty",
  226. col_type: 'text_2',
  227. })
  228. d.push({
  229. title: "最高击杀:" + data.maxKillTimes,
  230. url: "hiker://empty",
  231. col_type: 'text_2',
  232. })
  233. d.push({
  234. title: "最高治疗:" + data.maxCure,
  235. url: "hiker://empty",
  236. col_type: 'text_2',
  237. })
  238. /*d.push({
  239. title: "最高死亡:" + data.maxDeadTimes,
  240. url: "hiker://empty",
  241. col_type: 'text_2',
  242. })*/
  243. d.push({
  244. title: "最高救援:" + data.maxRescueTimes,
  245. url: "hiker://empty",
  246. col_type: 'text_2',
  247. })
  248. d.push({
  249. title: "最高生存时间:" + resultFormat(data.maxTotalLiveTime),
  250. url: "hiker://empty",
  251. col_type: 'text_2',
  252. })
  253. d.push({
  254. col_type: 'line_blank'
  255. })
  256. d.push({
  257. title: "夺冠次数:" + data.rank1Count,
  258. url: "hiker://empty",
  259. col_type: 'text_2',
  260. })
  261. d.push({
  262. title: "夺冠率:" + data.rank1Rate,
  263. url: "hiker://empty",
  264. col_type: 'text_2',
  265. })
  266. d.push({
  267. title: "前五次数:" + data.rankLe5Count,
  268. url: "hiker://empty",
  269. col_type: 'text_2',
  270. })
  271. d.push({
  272. title: "前五率:" + data.rankLe5Rate,
  273. url: "hiker://empty",
  274. col_type: 'text_2',
  275. })
  276. } else {
  277. d.push({
  278. title: res.message,
  279. col_type: 'long_text',
  280. })
  281. }
  282. }
  283. } else if (cate_select === '3') {
  284. if (current_page === '1') {
  285. let url = "https://gamedb.gamersky.com/yjwujian/hero/getHeroData?roleId="+roleId
  286. let res_json = fetch(url)
  287. let res = JSON.parse(res_json)
  288. let heroBest = res.data.heroBest
  289. let heroList = res.data.heroList
  290. d.push({
  291. title: "最佳英雄",
  292. url: "hiker://empty",
  293. col_type: 'text_1',
  294. })
  295. d.push({
  296. title: heroBest.hero,
  297. desc: "使用率:"+heroBest.useRate+"%",
  298. pic_url: "https:"+heroBest.backImage+"@Referer=https://www.gamersky.com/",
  299. url: "https:"+heroBest.backImage+"@Referer=https://www.gamersky.com/",
  300. col_type: 'movie_1_left_pic'
  301. })
  302. d.push({
  303. title: "胜场:" + heroBest.winRate,
  304. url: "hiker://empty",
  305. col_type: 'text_2',
  306. })
  307. d.push({
  308. title: "场均伤害:" + heroBest.avgDamage,
  309. url: "hiker://empty",
  310. col_type: 'text_2',
  311. })
  312. d.push({
  313. title: "K/D:" + heroBest.kd,
  314. url: "hiker://empty",
  315. col_type: 'text_2',
  316. })
  317. /*d.push({
  318. title: "游戏时长:" + resultFormat(heroBest.playTime),
  319. url: "hiker://empty",
  320. col_type: 'text_2',
  321. })*/
  322. d.push({
  323. col_type: 'line_blank'
  324. })
  325. d.push({
  326. title: "英雄数据",
  327. url: "hiker://empty",
  328. col_type: 'text_1',
  329. })
  330. heroList.forEach(hero => {
  331. d.push({
  332. title: hero.hero,
  333. desc: "使用率:"+hero.useRate+"%",
  334. pic_url: "https:"+hero.backImage+"@Referer=https://www.gamersky.com/",
  335. url: "https:"+hero.backImage+"@Referer=https://www.gamersky.com/",
  336. col_type: 'movie_1_left_pic'
  337. })
  338. d.push({
  339. title: "胜场:" + hero.winTimes,
  340. url: "hiker://empty",
  341. col_type: 'text_2',
  342. })
  343. d.push({
  344. title: "场均伤害:" + hero.avgDamage,
  345. url: "hiker://empty",
  346. col_type: 'text_2',
  347. })
  348. d.push({
  349. title: "K/D:" + hero.kd,
  350. url: "hiker://empty",
  351. col_type: 'text_2',
  352. })
  353. // d.push({
  354. // title: "游戏时长:" + resultFormat(hero.playTime),
  355. // url: "hiker://empty",
  356. // col_type: 'text_2',
  357. // })
  358. d.push({
  359. col_type: 'line_blank'
  360. })
  361. })
  362. }
  363. }/* else if (cate_select === '5') {
  364. d.push({
  365. desc: '600 && float',
  366. url: "https://api.xiaoheihe.cn/wiki/map_v2/?wiki_id=1203220&mapId=39",
  367. col_type: 'x5_webview_single'
  368. });
  369. }*/
  370. }
  371. setResult(d);
  372. }
  373. const setRoleId = params => {
  374. const role_path = "hiker://files/rules/js/TyrantGenesis_永劫无间用户绑定.js"
  375. let res_json = fetch("https://gamedb.gamersky.com/yjwujian/search/getSearchResult?serverId=163&roleName="+params.input)
  376. // let data = fetch(role_path)
  377. let res = JSON.parse(res_json)
  378. if (res.code === 0) {
  379. // data += (params.input+'\r\n')
  380. writeFile(role_path, res.data.roleId)
  381. refreshPage(false)
  382. return 'hiker://empty'
  383. } else {
  384. refreshPage(false)
  385. return 'toast://'+res.message
  386. }
  387. }
  388. const resultFormat = result => {
  389. let secondTime = parseInt(result);// 秒
  390. let minuteTime = 0;// 分
  391. let hourTime = 0;// 小时
  392. if(secondTime > 60) {//如果秒数大于60,将秒数转换成整数
  393. //获取分钟,除以60取整数,得到整数分钟
  394. minuteTime = parseInt(secondTime / 60);
  395. //获取秒数,秒数取佘,得到整数秒数
  396. secondTime = parseInt(secondTime % 60);
  397. //如果分钟大于60,将分钟转换成小时
  398. if(minuteTime > 60) {
  399. //获取小时,获取分钟除以60,得到整数小时
  400. hourTime = parseInt(minuteTime / 60);
  401. //获取小时后取佘的分,获取分钟除以60取佘的分
  402. minuteTime = parseInt(minuteTime % 60);
  403. }
  404. }
  405. let time = "" + parseInt(secondTime) + "秒";
  406. if(minuteTime > 0) {
  407. time = "" + parseInt(minuteTime) + "分" + time;
  408. }
  409. if(hourTime > 0) {
  410. time = "" + parseInt(hourTime) + "小时" + time;
  411. }
  412. return time;
  413. }