Use this script in order to easily switch between your accounts!
目前為
// ==UserScript==
// @name bonk.io Account Switcher
// @namespace http://tampermonkey.net/
// @version 1.2.0
// @description Use this script in order to easily switch between your accounts!
// @author kitaesq
// @match https://bonk.io/gameframe-release.html
// @icon https://www.google.com/s2/favicons?sz=64&domain=bonk.io
// @grant none
// ==/UserScript==
console.log("Loading account switcher...")
if (!window.kitaes) window.kitaes = {}
window.kitaes.accSwitcher = () => {
const accContainer = document.getElementById("guestOrAccountContainer")
if (!accContainer) {
setTimeout(window.kitaes.accSwitcher, 100)
console.log("trying again")
return
}
accContainer.children[0].style.margin = "0"
accContainer.children[1].style.margin = "0"
accContainer.style.height = "425px"
const main = document.createElement("div")
const mainStyle = {
position: "absolute",
left: "0",
right: "0",
bottom: "0",
height: "200px",
borderRadius: "7px",
backgroundColor: "var(--greyWindowBGColor)"
}
main.className = "windowShadow accountContainer"
Object.assign(main.style, mainStyle)
const mainHeader = document.createElement("div")
mainHeader.className = "windowTopBar windowTopBar_classic"
mainHeader.innerText = "Account Switcher"
mainHeader.style.position = "relative"
const headerButtons = document.createElement("div")
headerButtons.style.display = "flex"
headerButtons.style.position = "absolute"
headerButtons.style.right = "0px"
headerButtons.style.top = "0px"
headerButtons.style.height = "100%"
headerButtons.style.alignItems = "center"
const headerButtonStyle = {
height: "calc(100% - 10px)",
lineHeight: "20px",
marginLeft: "10px",
marginRight: "10px"
}
function createHeaderButton(text, onclick){
const button = document.createElement("div")
button.className = "brownButton brownButton_classic buttonShadow"
button.innerText = text
Object.assign(button.style, headerButtonStyle)
button.onclick = onclick
headerButtons.append(button)
}
createHeaderButton("Get Passwords", () => {
const csvString = ["usernames,passwords"]
for (const [username, password] of Object.entries(JSON.parse(localStorage.kitaes_accSwitcher))){
csvString.push(`${username},"${password.replace("\"", "\\\"")}"`)
}
const blob = new Blob([csvString.join("\n")])
const url = URL.createObjectURL(blob)
const link = document.createElement("a")
link.href = url
link.download = "passwords.csv"
link.click()
setTimeout(() => URL.revokeObjectURL(url), 10000)
})
mainHeader.append(headerButtons)
main.append(mainHeader)
const labelBox = document.createElement("div")
labelBox.className = "guestOrAccountContainerLabelBox guestOrAccountContainerLabelSingleLine"
labelBox.innerText = "Select an account to play with. New accounts will be added automatically"
labelBox.style.width = "670px"
main.append(labelBox)
const buttonContainer = document.createElement("div")
const deleteButtonContainer = document.createElement("div")
const buttonStyle = {
height: "40px",
lineHeight: "40px",
fontSize: "18px",
marginLeft: "12px",
marginRight: "12px",
flexGrow: "1",
flexBasis: "0px",
overflow: "hidden",
textOverflow: "ellipsis"
}
function addButton(username,password){
const button = document.createElement("div")
button.className = "brownButton brownButton_classic buttonShadow thickerText"
Object.assign(button.style, buttonStyle)
button.innerText = username
button.onclick = () => login(username, password)
buttonContainer.append(button)
const deleteButton = document.createElement("div")
deleteButton.className = "brownButton brownButton_classic buttonShadow mapeditor_leftbox_bottombutton"
deleteButton.style.backgroundImage = "url(../graphics/delete.png)"
deleteButton.onclick = () => {
deleteButton.classList.add("mapeditor_leftbox_deletebuttonconfirm")
deleteButton.onclick = () => {
button.remove()
deleteButton.remove()
delete accList[username]
localStorage.kitaes_accSwitcher = JSON.stringify(accList)
}
}
deleteButtonContainer.append(deleteButton)
}
const buttonContStyle = {
position: "absolute",
left: "12px",
right: "12px",
display: "flex",
}
Object.assign(buttonContainer.style, buttonContStyle)
Object.assign(deleteButtonContainer.style, buttonContStyle)
buttonContainer.style.bottom = "15px"
deleteButtonContainer.style.bottom = "-20px"
buttonContainer.style.justifyContent = "space-between"
deleteButtonContainer.style.justifyContent = "space-around"
main.append(buttonContainer)
main.append(deleteButtonContainer)
try{
var accList = JSON.parse(localStorage.kitaes_accSwitcher)
}
catch(e){
var accList = {}
localStorage.kitaes_accSwitcher = "{}"
}
function login(username,password){
loginwindow_username.value = username
loginwindow_password.value = password
accContainer.style.visibility = "hidden"
loginwindow_submitbutton.click()
guestOrAccountContainer_accountButton.click()
}
for (const a of Object.keys(accList)){
addButton(a, accList[a])
}
accContainer.append(main)
loginwindow_submitbutton.onclick = () => {
if (accList[loginwindow_username.value] === login_password.value) return
accList[loginwindow_username.value] = loginwindow_password.value
localStorage.kitaes_accSwitcher = JSON.stringify(accList)
addButton(loginwindow_username.value, loginwindow_password.value)
}
}
window.kitaes.accSwitcher()