@proak/fut
Version:
Node implementation of Fifa Ultimate Team
32 lines (29 loc) • 934 B
JavaScript
module.exports = {
parse: {
title (content) {
const TITLE_REGEX = /<title>(.*)<\/title>/
const result = content.match(TITLE_REGEX)
return result && result[1]
},
redirectUrl (content) {
const REDIRECT_URI_REGEX = /['"](.*)['"]/
const lines = content.split('\n')
const redirectLines = lines.filter(
line => line.indexOf('redirectUri') >= 0
)
const parts = redirectLines.map(str => {
const matched = str.match(REDIRECT_URI_REGEX)
return matched !== null ? matched[1] : ''
})
const result = parts.join('')
if (!result) throw new Error('Unknown Fifa FUT 18 login form response')
return result
},
email (content) {
const startIndex = content.indexOf('<strong>') + 8
const endIndex = content.indexOf('</strong>')
const result = content.slice(startIndex, endIndex).trim()
return result
}
}
}