Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AccChecker {
- constructor(){
- this.token = undefined
- }
- start(){
- this.getToken()
- }
- getToken(){
- this.token = document.getElementsByName('_xfToken')[0].value
- if(this.token){
- this.getAccounts()
- }
- }
- async getAccounts(){
- const accounts = document.querySelectorAll('.marketIndexItem')
- for(let account of accounts){
- const link = account.childNodes[3].childNodes[1].href
- const price = account.firstElementChild.innerText
- const id = account.id
- await this.checkAvailability(link, price)
- }
- }
- async checkAvailability(accountLink, price, id){
- let str = accountLink.split('/')
- str = [str[3], str[4]].join('/')
- const accPage = await fetch(`${accountLink}`)
- const htmlAcc = await accPage.text()
- const docAcc = new DOMParser().parseFromString(htmlAcc, "text/html")
- const tokenAcc = docAcc.querySelector(`.languageSwitcher`).href.split(`_xfToken=`)[1]
- console.log(tokenAcc)
- await fetch(`${accountLink}balance/check?price=${price}&&_xfRequestUri=/${str}/&_xfNoRedirect=1&_xfToken=${this.token}&_xfResponseType=json`)
- .then(response=>{
- if(response.status === 404){
- console.log('not found')
- }
- return response.json()
- })
- .then(json =>{
- console.log(json)
- // html = json.templateHtml
- // doc = new DOMParser().parseFromString(html, "text/html")
- // link = doc.querySelector(`.container`).childNodes[9].href
- if(json.templateHtml.indexOf('\u0410\u043a\u043a\u0430\u0443\u043d\u0442 \u0432\u0430\u043b\u0438\u0434\\')){
- fetch(`${accountLink}cancel-buy?_xfToken=${tokenAcc}`)
- }
- })
- .catch((err) =>{
- document.getElementById(id).innerHTML = ''
- })
- return true
- }
- }
- const checker = new AccChecker()
- checker.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement