Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add account linking #40

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions iitc-plugin-bannergress.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,12 @@ console.log('DEBUG insert missionsListHtml');
this.keycloak.logout(window.location.href);
}
}))
el.append($("<button>", {
text: "Link agent name",
click: async () => {
await this.linkAccount();
}
}))
}

const onLoggedOut = () => {
Expand Down Expand Up @@ -1225,6 +1231,42 @@ console.log('DEBUG insert missionsListHtml');

}

async linkAccount() {
try {
const agent = window.PLAYER.nickname;
let userInfo = await this.ajaxBannergress({
path: 'user',
dataType: "json"
});
if (userInfo.agent === agent) {
alert(`Your Bannergress account is already linked to ${agent}`);
return;
}
if (!confirm(`In order to link your Bannergress account to "${agent}", this will send a COMM message to the Bannergress Team`)) {
return;
}
if (userInfo.verificationAgent !== agent) {
userInfo = await this.ajaxBannergress({
path: 'user/claim',
type: 'POST',
dataType: "json",
data: {
agent: window.PLAYER.nickname
}
});
}
await postAjaxIntel("sendPlext", {
message: userInfo.verificationMessage,
latE6: -75_000_000,
lngE6: -40_000_000,
tab: "all"
});
alert("COMM message has been sent. It may take some time until a Bannergress Team member takes care of it. Please be patient.");
} catch (e) {
console.error("[bannergress] error linking account", e);
alert("Failed to start account linking: " + e);
}
}
}

PLUGIN.contexts = {};
Expand Down