Advertisement
mireska

Untitled

Sep 28th, 2021
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1.  
  2.  
  3. class AccChecker {
  4. constructor(){
  5. this.token = undefined
  6. }
  7. start(){
  8. this.getToken()
  9. }
  10. getToken(){
  11. this.token = document.getElementsByName('_xfToken')[0].value
  12. if(this.token){
  13. this.getAccounts()
  14. }
  15. }
  16. async getAccounts(){
  17. const accounts = document.querySelectorAll('.marketIndexItem')
  18. for(let account of accounts){
  19. const link = account.childNodes[3].childNodes[1].href
  20. const price = account.firstElementChild.innerText
  21. const id = account.id
  22. await this.checkAvailability(link, price)
  23. }
  24. }
  25. async checkAvailability(accountLink, price, id){
  26. let str = accountLink.split('/')
  27. str = [str[3], str[4]].join('/')
  28. const accPage = await fetch(`${accountLink}`)
  29. const htmlAcc = await accPage.text()
  30. const docAcc = new DOMParser().parseFromString(htmlAcc, "text/html")
  31. const tokenAcc = docAcc.querySelector(`.languageSwitcher`).href.split(`_xfToken=`)[1]
  32. console.log(tokenAcc)
  33. await fetch(`${accountLink}balance/check?price=${price}&&_xfRequestUri=/${str}/&_xfNoRedirect=1&_xfToken=${this.token}&_xfResponseType=json`)
  34. .then(response=>{
  35. if(response.status === 404){
  36. console.log('not found')
  37. }
  38. return response.json()
  39. })
  40. .then(json =>{
  41. console.log(json)
  42. // html = json.templateHtml
  43. // doc = new DOMParser().parseFromString(html, "text/html")
  44. // link = doc.querySelector(`.container`).childNodes[9].href
  45. if(json.templateHtml.indexOf('\u0410\u043a\u043a\u0430\u0443\u043d\u0442 \u0432\u0430\u043b\u0438\u0434\\')){
  46. fetch(`${accountLink}cancel-buy?_xfToken=${tokenAcc}`)
  47. }
  48. })
  49. .catch((err) =>{
  50. document.getElementById(id).innerHTML = ''
  51. })
  52. return true
  53. }
  54. }
  55.  
  56. const checker = new AccChecker()
  57. checker.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement