This repository has been archived on 2026-01-04. You can view files and clone it, but cannot push or open issues or pull requests.
polyplus/js/places/place-join.js
StarManTheGamer bf6e9048c0 Revert "chore: format code with Prettier"
This reverts commit 70241eead6.
2024-05-27 17:04:02 -05:00

45 lines
No EOL
1.5 KiB
JavaScript

/*
DISABLED FEATURE
*/
!(() => {
return
const PlaceID = parseInt(window.location.pathname.split('/')[2])
fetch('https://polytoria.com/home')
.then(response => {
if (!response.ok) {
throw new Error('Network not ok')
}
return response.text()
})
.then(data => {
const Parser = new DOMParser()
const Doc = Parser.parseFromString(data, 'text/html')
fetch('https://polytoria.com/api/places/join',{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Csrf-Token': Doc.querySelector('[name="_csrf"]').value
},
body: JSON.stringify({
'placeID': PlaceID
})
})
.then(response => {
if (!response.ok) {
throw new Error('Network not ok')
}
return response.json()
})
.then(data => {
if (data.success !== true) {throw new Error(data.message)}
setTimeout(function(){
window.location.href = 'polytoria://client/' + data.token
window.location.href = 'https://polytoria.com/places/' + PlaceID
}, 5000)
})
.catch(error => {console.log(error)})
})
})();