Diving-Fish / maimaidx-prober

舞萌 DX 查分器
https://www.diving-fish.com/maimaidx/prober
MIT License
711 stars 53 forks source link

dev console导入代码fetch化 #66

Closed esterTion closed 1 year ago

esterTion commented 1 year ago

感觉2023了还在$.ajax {async:false}有点不文明(x

((u,p)=>[0,1,2,3,4].reduce(async(promise, diff)=>{
  await promise
  var diffName = ['Basic', 'Advanced', 'Expert', 'Master', 'Re:Master'][diff]
  var url = 'https://maimai.wahlap.com/maimai-mobile/record/musicGenre/search/?genre=99&diff='+diff
  return fetch(url)
  .then(r => {if(r.url!=url)throw new Error(diffName+' 获取分数出错');return r.text()})
  .then(res => fetch('https://www.diving-fish.com/api/pageparser/page', {
    method: 'POST',
    headers:(new Headers({'Content-Type':'text/plain'})),
    body: "<login><u>"+u+"</u><p>"+p+"</p></login>" + res.match(/<html.*>([\s\S]*)<\/html>/)[1].replace(/\s+/g,' ')
  }))
  .then(r => r.json())
  .then(res => {console.log(diffName, res.message, res);if(res.message!='success')throw new Error(diffName+' 上传分数出错')})
}, Promise.resolve()))
("USERNAME", "PASSWORD");

当然我没有测过微信那个浏览器支不支持,按理说应该都可以了吧。 (我是自己做了抓net登录token地址扔给电脑,在电脑上上传的)