diff --git a/.dist/channel.js b/.dist/channel.js index f2d1c2e..7377cc1 100644 --- a/.dist/channel.js +++ b/.dist/channel.js @@ -361,7 +361,7 @@ class Channel { if (!this.hasunreads) { return; } - fetch(this.info.api.toString() + "/channels/" + this.snowflake + "/messages/" + this.lastmessageid + "/ack", { + fetch(this.info.api + "/channels/" + this.snowflake + "/messages/" + this.lastmessageid + "/ack", { method: "POST", headers: this.headers, body: JSON.stringify({}) @@ -429,7 +429,7 @@ class Channel { return div; } createChannel(name, type) { - fetch(this.info.api.toString() + "/guilds/" + this.guild.id + "/channels", { + fetch(this.info.api + "/guilds/" + this.guild.id + "/channels", { method: "POST", headers: this.headers, body: JSON.stringify({ @@ -452,7 +452,7 @@ class Channel { ["mdbox", "Channel topic:", this.topic, function () { topic = this.value; }], ["checkbox", "NSFW Channel", this.nsfw, function () { nsfw = this.checked; }], ["button", "", "submit", () => { - fetch(this.info.api.toString() + "/channels/" + thisid, { + fetch(this.info.api + "/channels/" + thisid, { method: "PATCH", headers: this.headers, body: JSON.stringify({ @@ -475,7 +475,7 @@ class Channel { console.log(full); } deleteChannel() { - fetch(this.info.api.toString() + "/channels/" + this.snowflake, { + fetch(this.info.api + "/channels/" + this.snowflake, { method: "DELETE", headers: this.headers }); @@ -518,7 +518,7 @@ class Channel { return snowflake.getObject(); } else { - const gety = await fetch(this.info.api.toString() + "/channels/" + this.snowflake + "/messages?limit=1&around=" + id, { headers: this.headers }); + const gety = await fetch(this.info.api + "/channels/" + this.snowflake + "/messages?limit=1&around=" + id, { headers: this.headers }); const json = await gety.json(); return new Message(json[0], this); } @@ -554,7 +554,7 @@ class Channel { return; } ; - const j = await fetch(this.info.api.toString() + "/channels/" + this.snowflake + "/messages?limit=100", { + const j = await fetch(this.info.api + "/channels/" + this.snowflake + "/messages?limit=100", { headers: this.headers, }); const response = await j.json(); @@ -591,7 +591,7 @@ class Channel { if (id === this.lastmessage.id) { return; } - await fetch(this.info.api.toString() + "/channels/" + this.id + "/messages?limit=100&after=" + id, { + await fetch(this.info.api + "/channels/" + this.id + "/messages?limit=100&after=" + id, { headers: this.headers }).then((j) => { return j.json(); }).then(response => { let previd = SnowFlake.getSnowFlakeFromID(id, Message); @@ -622,7 +622,7 @@ class Channel { if (this.topid && id === this.topid.id) { return; } - await fetch(this.info.api.toString() + "/channels/" + this.snowflake + "/messages?before=" + id + "&limit=100", { + await fetch(this.info.api + "/channels/" + this.snowflake + "/messages?before=" + id + "&limit=100", { headers: this.headers }).then((j) => { return j.json(); }).then((response) => { if (response.length < 100) { @@ -725,7 +725,7 @@ class Channel { return; } this.typing = new Date().getTime() + 6000; - fetch(this.info.api.toString() + "/channels/" + this.snowflake + "/typing", { + fetch(this.info.api + "/channels/" + this.snowflake + "/typing", { method: "POST", headers: this.headers }); @@ -768,7 +768,7 @@ class Channel { body.message_reference = replyjson; } console.log(body); - return await fetch(this.info.api.toString() + "/channels/" + this.snowflake + "/messages", { + return await fetch(this.info.api + "/channels/" + this.snowflake + "/messages", { method: "POST", headers: this.headers, body: JSON.stringify(body) @@ -789,7 +789,7 @@ class Channel { console.log(attachments[i]); formData.append("files[" + i + "]", attachments[i]); } - return await fetch(this.info.api.toString() + "/channels/" + this.snowflake + "/messages", { + return await fetch(this.info.api + "/channels/" + this.snowflake + "/messages", { method: 'POST', body: formData, headers: { "Authorization": this.headers.Authorization } @@ -877,7 +877,7 @@ class Channel { } } async addRoleToPerms(role) { - await fetch(this.info.api.toString() + "/channels/" + this.snowflake + "/permissions/" + role.snowflake, { + await fetch(this.info.api + "/channels/" + this.snowflake + "/permissions/" + role.snowflake, { method: "PUT", headers: this.headers, body: JSON.stringify({ @@ -895,7 +895,7 @@ class Channel { const permission = this.permission_overwrites.get(id); permission.allow = perms.allow; permission.deny = perms.deny; - await fetch(this.info.api.toString() + "/channels/" + this.snowflake + "/permissions/" + id, { + await fetch(this.info.api + "/channels/" + this.snowflake + "/permissions/" + id, { method: "PUT", headers: this.headers, body: JSON.stringify({ diff --git a/.dist/guild.js b/.dist/guild.js index 744936d..ac7fe2f 100644 --- a/.dist/guild.js +++ b/.dist/guild.js @@ -117,7 +117,7 @@ class Guild { noti ], ["button", "", "submit", _ => { - fetch(this.info.api.toString() + "/v9/users/@me/guilds/settings", { + fetch(this.info.api + "/v9/users/@me/guilds/settings", { method: "PATCH", headers: this.headers, body: JSON.stringify({ @@ -161,7 +161,7 @@ class Guild { full.show(); } async leave() { - return fetch(this.info.api.toString() + "/users/@me/guilds/" + this.snowflake, { + return fetch(this.info.api + "/users/@me/guilds/" + this.snowflake, { method: "DELETE", headers: this.headers }); @@ -211,7 +211,7 @@ class Guild { if (serverbug) { for (const thing of build) { console.log(build, thing); - fetch(this.info.api.toString() + "/v9/guilds/" + this.snowflake + "/channels", { + fetch(this.info.api + "/v9/guilds/" + this.snowflake + "/channels", { method: "PATCH", headers: this.headers, body: JSON.stringify([thing]) @@ -219,7 +219,7 @@ class Guild { } } else { - fetch(this.info.api.toString() + "/v9/guilds/" + this.snowflake + "/channels", { + fetch(this.info.api + "/v9/guilds/" + this.snowflake + "/channels", { method: "PATCH", headers: this.headers, body: JSON.stringify(build) @@ -245,7 +245,7 @@ class Guild { if (this.properties.icon != null) { const img = document.createElement("img"); img.classList.add("pfp", "servericon"); - img.src = this.info.cdn.toString() + "/icons/" + this.properties.id + "/" + this.properties.icon + ".png"; + img.src = this.info.cdn + "/icons/" + this.properties.id + "/" + this.properties.icon + ".png"; divy.appendChild(img); img.onclick = () => { console.log(this.loadGuild); @@ -311,7 +311,7 @@ class Guild { full.show(); } async delete() { - return fetch(this.info.api.toString() + "/guilds/" + this.snowflake + "/delete", { + return fetch(this.info.api + "/guilds/" + this.snowflake + "/delete", { method: "POST", headers: this.headers, }); @@ -364,7 +364,7 @@ class Guild { } } this.unreads(); - fetch(this.info.api.toString() + "/v9/read-states/ack-bulk", { + fetch(this.info.api + "/v9/read-states/ack-bulk", { method: "POST", headers: this.headers, body: JSON.stringify(build) @@ -487,14 +487,14 @@ class Guild { this.printServers(); } createChannel(name, type) { - fetch(this.info.api.toString() + "/guilds/" + this.snowflake + "/channels", { + fetch(this.info.api + "/guilds/" + this.snowflake + "/channels", { method: "POST", headers: this.headers, body: JSON.stringify({ name: name, type: type }) }); } async createRole(name) { - const fetched = await fetch(this.info.api.toString() + "/guilds/" + this.snowflake + "roles", { + const fetched = await fetch(this.info.api + "/guilds/" + this.snowflake + "roles", { method: "POST", headers: this.headers, body: JSON.stringify({ @@ -513,7 +513,7 @@ class Guild { const role = this.roleids[id]; role.permissions.allow = perms.allow; role.permissions.deny = perms.deny; - await fetch(this.info.api.toString() + "/guilds/" + this.snowflake + "/roles/" + this.snowflake, { + await fetch(this.info.api + "/guilds/" + this.snowflake + "/roles/" + this.snowflake, { method: "PATCH", headers: this.headers, body: JSON.stringify({ diff --git a/.dist/index.js b/.dist/index.js index 93f69c5..2fe0603 100644 --- a/.dist/index.js +++ b/.dist/index.js @@ -26,36 +26,27 @@ thisuser.initwebsocket().then(_ => { const userinfo = document.getElementById("userinfo"); const userdock = document.getElementById("userdock"); userinfo.addEventListener("click", function (event) { - const table = document.createElement("table"); + const table = document.createElement("div"); for (const thing of Object.values(users.users)) { const specialuser = thing; console.log(specialuser.pfpsrc); - const tr = document.createElement("tr"); - const td = document.createElement("td"); - const userinfo = document.createElement("table"); - userinfo.classList.add("switchtable"); - const row = document.createElement("tr"); - userinfo.append(row); - const pfpcell = document.createElement("td"); - row.append(pfpcell); + const userinfo = document.createElement("div"); + userinfo.classList.add("flexltr", "switchtable"); const pfp = document.createElement("img"); - pfpcell.append(pfp); - const usertd = document.createElement("td"); - row.append(usertd); + userinfo.append(pfp); const user = document.createElement("div"); - usertd.append(user); + userinfo.append(user); user.append(specialuser.username); user.append(document.createElement("br")); const span = document.createElement("span"); - span.textContent = specialuser.serverurls.wellknown.hostname; + span.textContent = specialuser.serverurls.wellknown.replace("https://", "").replace("http://", ""); user.append(span); + user.classList.add("userinfo"); span.classList.add("serverURL"); pfp.src = specialuser.pfpsrc; pfp.classList.add("pfp"); - td.append(userinfo); - tr.append(td); - table.append(tr); - tr.addEventListener("click", _ => { + table.append(userinfo); + userinfo.addEventListener("click", _ => { thisuser.unload(); document.getElementById("loading").classList.remove("doneloading"); document.getElementById("loading").classList.add("loading"); @@ -72,14 +63,13 @@ thisuser.initwebsocket().then(_ => { }); } { - const tr = document.createElement("tr"); - const td = document.createElement("td"); - tr.append(td); + const td = document.createElement("div"); + td.classList.add("switchtable"); td.append("Switch accounts ⇌"); td.addEventListener("click", _ => { window.location.href = "/login.html"; }); - table.append(tr); + table.append(td); } table.classList.add("accountSwitcher"); if (Contextmenu.currentmenu != "") { @@ -87,7 +77,7 @@ thisuser.initwebsocket().then(_ => { } Contextmenu.currentmenu = table; console.log(table); - userdock.before(table); + document.body.append(table); event.stopImmediatePropagation(); }); } diff --git a/.dist/localuser.js b/.dist/localuser.js index 9954251..7f8875c 100644 --- a/.dist/localuser.js +++ b/.dist/localuser.js @@ -469,7 +469,7 @@ class Localuser { else { parsed = inviteurl; } - fetch(this.info.api.toString() + "/v9/invites/" + parsed, { + fetch(this.info.api + "/v9/invites/" + parsed, { method: "POST", headers: this.headers, }).then(r => r.json()).then(_ => { @@ -492,7 +492,7 @@ class Localuser { content.textContent = "Loading..."; const full = new Fullscreen(["html", content]); full.show(); - const res = await fetch(this.info.api.toString() + "/v9/discoverable-guilds?limit=50", { + const res = await fetch(this.info.api + "/v9/discoverable-guilds?limit=50", { headers: this.headers }); const json = await res.json(); @@ -509,7 +509,7 @@ class Localuser { const banner = document.createElement("img"); banner.classList.add("banner"); banner.crossOrigin = "anonymous"; - banner.src = this.info.cdn.toString() + "icons/" + guild.id + "/" + guild.banner + ".png?size=256"; + banner.src = this.info.cdn + "icons/" + guild.id + "/" + guild.banner + ".png?size=256"; banner.alt = ""; content.appendChild(banner); } @@ -518,7 +518,7 @@ class Localuser { const img = document.createElement("img"); img.classList.add("icon"); img.crossOrigin = "anonymous"; - img.src = this.info.cdn.toString() + (guild.icon ? ("/icons/" + guild.id + "/" + guild.icon + ".png?size=48") : "/embed/avatars/3.png"); + img.src = this.info.cdn + (guild.icon ? ("/icons/" + guild.id + "/" + guild.icon + ".png?size=48") : "/embed/avatars/3.png"); img.alt = ""; nameContainer.appendChild(img); const name = document.createElement("h3"); @@ -529,7 +529,7 @@ class Localuser { desc.textContent = guild.description; content.appendChild(desc); content.addEventListener("click", async () => { - const joinRes = await fetch(this.info.api.toString() + "/v9/guilds/" + guild.id + "/members/@me", { + const joinRes = await fetch(this.info.api + "/v9/guilds/" + guild.id + "/members/@me", { method: "PUT", headers: this.headers }); @@ -588,7 +588,7 @@ class Localuser { var reader = new FileReader(); reader.readAsDataURL(file); reader.onload = () => { - fetch(this.info.api.toString() + "/users/@me", { + fetch(this.info.api + "/users/@me", { method: "PATCH", headers: this.headers, body: JSON.stringify({ @@ -598,7 +598,7 @@ class Localuser { }; } updatepronouns(pronouns) { - fetch(this.info.api.toString() + "/users/@me/profile", { + fetch(this.info.api + "/users/@me/profile", { method: "PATCH", headers: this.headers, body: JSON.stringify({ @@ -607,7 +607,7 @@ class Localuser { }); } updatebio(bio) { - fetch(this.info.api.toString() + "/v9/users/@me/profile", { + fetch(this.info.api + "/v9/users/@me/profile", { method: "PATCH", headers: this.headers, body: JSON.stringify({ @@ -730,7 +730,7 @@ class Localuser { const security = settings.addButton("Account Security"); if (this.mfa_enabled) { security.addTextInput("Disable 2FA, totp code:", _ => { - fetch(this.info.api.toString() + "/users/@me/mfa/totp/disable", { + fetch(this.info.api + "/users/@me/mfa/totp/disable", { method: "POST", headers: this.headers, body: JSON.stringify({ @@ -762,7 +762,7 @@ class Localuser { ["textbox", "Account password:", "", function () { password = this.value; }], ["textbox", "Code:", "", function () { code = this.value; }], ["button", "", "Submit", () => { - fetch(this.info.api.toString() + "/users/@me/mfa/totp/enable/", { + fetch(this.info.api + "/users/@me/mfa/totp/enable/", { method: "POST", headers: this.headers, body: JSON.stringify({ @@ -800,7 +800,7 @@ class Localuser { connectionContainer ], () => { }, async () => { connectionContainer.innerHTML = ""; - const res = await fetch(this.info.api.toString() + "/v9/connections", { + const res = await fetch(this.info.api + "/v9/connections", { headers: this.headers }); const json = await res.json(); @@ -810,7 +810,7 @@ class Localuser { container.textContent = key.charAt(0).toUpperCase() + key.slice(1); if (connection.enabled) { container.addEventListener("click", async () => { - const connectionRes = await fetch(this.info.api.toString() + "/v9/connections/" + key + "/authorize", { + const connectionRes = await fetch(this.info.api + "/v9/connections/" + key + "/authorize", { headers: this.headers }); const connectionJSON = await connectionRes.json(); @@ -838,7 +838,7 @@ class Localuser { async () => { if (appName.trim().length == 0) return alert("Please enter a name for the application."); - const res = await fetch(this.info.api.toString() + "/v9/applications", { + const res = await fetch(this.info.api + "/v9/applications", { method: "POST", headers: this.headers, body: JSON.stringify({ @@ -856,7 +856,7 @@ class Localuser { ] ], () => { }, async () => { appListContainer.innerHTML = ""; - const res = await fetch(this.info.api.toString() + "/v9/applications", { + const res = await fetch(this.info.api + "/v9/applications", { headers: this.headers }); const json = await res.json(); @@ -865,7 +865,7 @@ class Localuser { if (application.cover_image) { const cover = document.createElement("img"); cover.crossOrigin = "anonymous"; - cover.src = this.info.cdn.toString() + "/app-icons/" + application.id + "/" + application.cover_image + ".png?size=256"; + cover.src = this.info.cdn + "/app-icons/" + application.id + "/" + application.cover_image + ".png?size=256"; cover.alt = ""; cover.loading = "lazy"; container.appendChild(cover); @@ -882,7 +882,7 @@ class Localuser { }); } async manageApplication(appId = "") { - const res = await fetch(this.info.api.toString() + "/v9/applications/" + appId, { + const res = await fetch(this.info.api + "/v9/applications/" + appId, { headers: this.headers }); const json = await res.json(); @@ -899,7 +899,7 @@ class Localuser { fields.description = event.target.value; }], ["vdiv", - json.icon ? ["img", this.info.cdn.toString() + "/app-icons/" + appId + "/" + json.icon + ".png?size=128", [128, 128]] : ["text", "No icon"], + json.icon ? ["img", this.info.cdn + "/app-icons/" + appId + "/" + json.icon + ".png?size=128", [128, 128]] : ["text", "No icon"], ["fileupload", "Application icon:", event => { const reader = new FileReader(); reader.readAsDataURL(event.target.files[0]); @@ -930,7 +930,7 @@ class Localuser { "", "Save changes", async () => { - const updateRes = await fetch(this.info.api.toString() + "/v9/applications/" + appId, { + const updateRes = await fetch(this.info.api + "/v9/applications/" + appId, { method: "PATCH", headers: this.headers, body: JSON.stringify(fields) @@ -950,7 +950,7 @@ class Localuser { if (!json.bot) { if (!confirm("Are you sure you want to add a bot to this application? There's no going back.")) return; - const updateRes = await fetch(this.info.api.toString() + "/v9/applications/" + appId + "/bot", { + const updateRes = await fetch(this.info.api + "/v9/applications/" + appId + "/bot", { method: "POST", headers: this.headers }); @@ -966,7 +966,7 @@ class Localuser { appDialog.show(); } async manageBot(appId = "") { - const res = await fetch(this.info.api.toString() + "/v9/applications/" + appId, { + const res = await fetch(this.info.api + "/v9/applications/" + appId, { headers: this.headers }); const json = await res.json(); @@ -974,7 +974,7 @@ class Localuser { return alert("For some reason, this application doesn't have a bot (yet)."); const fields = { username: json.bot.username, - avatar: json.bot.avatar ? (this.info.cdn.toString() + "/app-icons/" + appId + "/" + json.bot.avatar + ".png?size=256") : "" + avatar: json.bot.avatar ? (this.info.cdn + "/app-icons/" + appId + "/" + json.bot.avatar + ".png?size=256") : "" }; const botDialog = new Fullscreen(["vdiv", ["title", @@ -1000,7 +1000,7 @@ class Localuser { "", "Save changes", async () => { - const updateRes = await fetch(this.info.api.toString() + "/v9/applications/" + appId + "/bot", { + const updateRes = await fetch(this.info.api + "/v9/applications/" + appId + "/bot", { method: "PATCH", headers: this.headers, body: JSON.stringify(fields) @@ -1019,7 +1019,7 @@ class Localuser { async () => { if (!confirm("Are you sure you want to reset the bot token? Your bot will stop working until you update it.")) return; - const updateRes = await fetch(this.info.api.toString() + "/v9/applications/" + appId + "/bot/reset", { + const updateRes = await fetch(this.info.api + "/v9/applications/" + appId + "/bot/reset", { method: "POST", headers: this.headers }); diff --git a/.dist/login.js b/.dist/login.js index 894bf68..beb4de4 100644 --- a/.dist/login.js +++ b/.dist/login.js @@ -65,10 +65,16 @@ class Specialuser { console.error("specialuser can't construct from another specialuser"); } this.serverurls = json.serverurls; - this.serverurls.api = new URL(this.serverurls.api); - this.serverurls.cdn = new URL(this.serverurls.cdn); - this.serverurls.gateway = new URL(this.serverurls.gateway); - this.serverurls.wellknown = new URL(this.serverurls.wellknown); + let apistring = new URL(json.serverurls.api).toString(); + apistring = apistring.replace(/\/(v\d+\/?)?$/, "") + "/v9"; + this.serverurls.api = apistring; + this.serverurls.cdn = new URL(json.serverurls.cdn).toString().replace(/\/$/, ""); + this.serverurls.gateway = new URL(json.serverurls.gateway).toString().replace(/\/$/, ""); + ; + this.serverurls.wellknown = new URL(json.serverurls.wellknown).toString().replace(/\/$/, ""); + ; + this.serverurls.login = new URL(json.serverurls.login).toString().replace(/\/$/, ""); + ; this.email = json.email; this.token = json.token; this.loggedin = json.loggedin; diff --git a/.dist/markdown.js b/.dist/markdown.js index f48e2ab..dedcb4c 100644 --- a/.dist/markdown.js +++ b/.dist/markdown.js @@ -455,7 +455,7 @@ class MarkDown { emojiElem.classList.add("md-emoji"); emojiElem.classList.add(isEmojiOnly ? "bigemoji" : "smallemoji"); emojiElem.crossOrigin = "anonymous"; - emojiElem.src = this.info.cdn.toString() + "emojis/" + parts[2] + "." + (parts[1] ? "gif" : "png") + "?size=32"; + emojiElem.src = this.info.cdn + "emojis/" + parts[2] + "." + (parts[1] ? "gif" : "png") + "?size=32"; emojiElem.alt = buildjoin; emojiElem.loading = "lazy"; span.appendChild(emojiElem); diff --git a/.dist/member.js b/.dist/member.js index 9fa6449..db29fef 100644 --- a/.dist/member.js +++ b/.dist/member.js @@ -16,7 +16,7 @@ class Member { navigator.clipboard.writeText(this.id); }); this.contextmenu.addbutton("Message user", function () { - fetch(this.info.api.toString() + "/v9/users/@me/channels", { method: "POST", + fetch(this.info.api + "/v9/users/@me/channels", { method: "POST", body: JSON.stringify({ "recipients": [this.id] }), headers: this.headers }); diff --git a/.dist/message.js b/.dist/message.js index dd4301b..301eb05 100644 --- a/.dist/message.js +++ b/.dist/message.js @@ -79,7 +79,7 @@ class Message { break; } } - fetch(this.info.api.toString() + "/channels/" + this.channel.id + "/messages/" + this.id + "/reactions/" + encodeURIComponent(emoji) + "/@me", { + fetch(this.info.api + "/channels/" + this.channel.id + "/messages/" + this.id + "/reactions/" + encodeURIComponent(emoji) + "/@me", { method: remove ? "DELETE" : "PUT", headers: this.headers, }); @@ -184,14 +184,14 @@ class Message { return build; } async edit(content) { - return await fetch(this.info.api.toString() + "/channels/" + this.channel.snowflake + "/messages/" + this.id, { + return await fetch(this.info.api + "/channels/" + this.channel.snowflake + "/messages/" + this.id, { method: "PATCH", headers: this.headers, body: JSON.stringify({ content: content }) }); } delete() { - fetch(`${this.info.api.toString()}/channels/${this.channel.snowflake}/messages/${this.id}`, { + fetch(`${this.info.api}/channels/${this.channel.snowflake}/messages/${this.id}`, { headers: this.headers, method: "DELETE", }); diff --git a/.dist/user.js b/.dist/user.js index 84c3403..2e17f5a 100644 --- a/.dist/user.js +++ b/.dist/user.js @@ -48,7 +48,7 @@ class User { navigator.clipboard.writeText(this.id.id); }); this.contextmenu.addbutton("Message user", function () { - fetch(this.info.api.toString() + "/v9/users/@me/channels", { method: "POST", + fetch(this.info.api + "/v9/users/@me/channels", { method: "POST", body: JSON.stringify({ "recipients": [this.id.id] }), headers: this.localuser.headers }); @@ -141,10 +141,10 @@ class User { return this.avatar; } if (this.avatar != null) { - return this.info.cdn.toString() + "/avatars/" + this.id + "/" + this.avatar + ".png"; + return this.info.cdn + "/avatars/" + this.id + "/" + this.avatar + ".png"; } else { - return this.info.cdn.toString() + "/embed/avatars/3.png"; + return this.info.cdn + "/embed/avatars/3.png"; } } createjankpromises() { diff --git a/webpage/channel.ts b/webpage/channel.ts index 2f3d6e0..efefcd3 100644 --- a/webpage/channel.ts +++ b/webpage/channel.ts @@ -369,7 +369,7 @@ class Channel{ if(!this.hasunreads){ return; } - fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/messages/"+this.lastmessageid+"/ack",{ + fetch(this.info.api+"/channels/"+this.snowflake+"/messages/"+this.lastmessageid+"/ack",{ method:"POST", headers:this.headers, body:JSON.stringify({}) @@ -437,7 +437,7 @@ class Channel{ return div; } createChannel(name:string,type:number){ - fetch(this.info.api.toString()+"/guilds/"+this.guild.id+"/channels",{ + fetch(this.info.api+"/guilds/"+this.guild.id+"/channels",{ method:"POST", headers:this.headers, body:JSON.stringify({ @@ -461,7 +461,7 @@ class Channel{ ["mdbox","Channel topic:",this.topic,function(){topic=this.value}], ["checkbox","NSFW Channel",this.nsfw,function(){nsfw=this.checked}], ["button","","submit",()=>{ - fetch(this.info.api.toString()+"/channels/"+thisid,{ + fetch(this.info.api+"/channels/"+thisid,{ method:"PATCH", headers:this.headers, body:JSON.stringify({ @@ -485,7 +485,7 @@ class Channel{ console.log(full) } deleteChannel(){ - fetch(this.info.api.toString()+"/channels/"+this.snowflake,{ + fetch(this.info.api+"/channels/"+this.snowflake,{ method:"DELETE", headers:this.headers }) @@ -527,7 +527,7 @@ class Channel{ if(snowflake.getObject()){ return snowflake.getObject(); }else{ - const gety=await fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/messages?limit=1&around="+id,{headers:this.headers}) + const gety=await fetch(this.info.api+"/channels/"+this.snowflake+"/messages?limit=1&around="+id,{headers:this.headers}) const json=await gety.json(); return new Message(json[0],this); } @@ -560,7 +560,7 @@ class Channel{ lastmessage:Message; async putmessages(){ if(this.allthewayup){return}; - const j=await fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/messages?limit=100",{ + const j=await fetch(this.info.api+"/channels/"+this.snowflake+"/messages?limit=100",{ headers: this.headers, }); @@ -597,7 +597,7 @@ class Channel{ if(id===this.lastmessage.id){ return; } - await fetch(this.info.api.toString()+"/channels/"+this.id+"/messages?limit=100&after="+id,{ + await fetch(this.info.api+"/channels/"+this.id+"/messages?limit=100&after="+id,{ headers:this.headers }).then((j)=>{return j.json()}).then(response=>{ let previd:SnowFlake=SnowFlake.getSnowFlakeFromID(id,Message); @@ -628,7 +628,7 @@ class Channel{ return; } - await fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/messages?before="+id+"&limit=100",{ + await fetch(this.info.api+"/channels/"+this.snowflake+"/messages?before="+id+"&limit=100",{ headers:this.headers }).then((j)=>{return j.json()}).then((response:messagejson[])=>{ if(response.length<100){ @@ -727,7 +727,7 @@ class Channel{ return; } this.typing=new Date().getTime()+6000; - fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/typing",{ + fetch(this.info.api+"/channels/"+this.snowflake+"/typing",{ method:"POST", headers:this.headers }) @@ -767,7 +767,7 @@ class Channel{ body.message_reference=replyjson; } console.log(body) - return await fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/messages",{ + return await fetch(this.info.api+"/channels/"+this.snowflake+"/messages",{ method:"POST", headers:this.headers, body:JSON.stringify(body) @@ -787,7 +787,7 @@ class Channel{ console.log(attachments[i]) formData.append("files["+i+"]",attachments[i]); } - return await fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/messages", { + return await fetch(this.info.api+"/channels/"+this.snowflake+"/messages", { method: 'POST', body: formData, headers:{"Authorization":this.headers.Authorization} @@ -868,7 +868,7 @@ class Channel{ } } async addRoleToPerms(role:Role){ - await fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/permissions/"+role.snowflake,{ + await fetch(this.info.api+"/channels/"+this.snowflake+"/permissions/"+role.snowflake,{ method:"PUT", headers:this.headers, body:JSON.stringify({ @@ -886,7 +886,7 @@ class Channel{ const permission=this.permission_overwrites.get(id); permission.allow=perms.allow; permission.deny=perms.deny; - await fetch(this.info.api.toString()+"/channels/"+this.snowflake+"/permissions/"+id,{ + await fetch(this.info.api+"/channels/"+this.snowflake+"/permissions/"+id,{ method:"PUT", headers:this.headers, body:JSON.stringify({ diff --git a/webpage/guild.ts b/webpage/guild.ts index 990dfab..282eb1f 100644 --- a/webpage/guild.ts +++ b/webpage/guild.ts @@ -128,7 +128,7 @@ class Guild{ noti ], ["button","","submit",_=>{ - fetch(this.info.api.toString()+"/v9/users/@me/guilds/settings",{ + fetch(this.info.api+"/v9/users/@me/guilds/settings",{ method:"PATCH", headers:this.headers, body:JSON.stringify({ @@ -173,7 +173,7 @@ class Guild{ full.show(); } async leave(){ - return fetch(this.info.api.toString()+"/users/@me/guilds/"+this.snowflake,{ + return fetch(this.info.api+"/users/@me/guilds/"+this.snowflake,{ method:"DELETE", headers:this.headers }) @@ -221,14 +221,14 @@ class Guild{ if(serverbug){ for(const thing of build){ console.log(build,thing) - fetch(this.info.api.toString()+"/v9/guilds/"+this.snowflake+"/channels",{ + fetch(this.info.api+"/v9/guilds/"+this.snowflake+"/channels",{ method:"PATCH", headers:this.headers, body:JSON.stringify([thing]) }); } }else{ - fetch(this.info.api.toString()+"/v9/guilds/"+this.snowflake+"/channels",{ + fetch(this.info.api+"/v9/guilds/"+this.snowflake+"/channels",{ method:"PATCH", headers:this.headers, body:JSON.stringify(build) @@ -256,7 +256,7 @@ class Guild{ if(this.properties.icon!=null){ const img=document.createElement("img"); img.classList.add("pfp","servericon"); - img.src=this.info.cdn.toString()+"/icons/"+this.properties.id+"/"+this.properties.icon+".png"; + img.src=this.info.cdn+"/icons/"+this.properties.id+"/"+this.properties.icon+".png"; divy.appendChild(img) img.onclick=()=>{ console.log(this.loadGuild) @@ -323,7 +323,7 @@ class Guild{ full.show(); } async delete(){ - return fetch(this.info.api.toString()+"/guilds/"+this.snowflake+"/delete",{ + return fetch(this.info.api+"/guilds/"+this.snowflake+"/delete",{ method:"POST", headers:this.headers, }) @@ -372,7 +372,7 @@ class Guild{ } } this.unreads(); - fetch(this.info.api.toString()+"/v9/read-states/ack-bulk",{ + fetch(this.info.api+"/v9/read-states/ack-bulk",{ method:"POST", headers:this.headers, body:JSON.stringify(build) @@ -499,14 +499,14 @@ class Guild{ this.printServers(); } createChannel(name:string,type:number){ - fetch(this.info.api.toString()+"/guilds/"+this.snowflake+"/channels",{ + fetch(this.info.api+"/guilds/"+this.snowflake+"/channels",{ method:"POST", headers:this.headers, body:JSON.stringify({name: name, type: type}) }) } async createRole(name:string){ - const fetched=await fetch(this.info.api.toString()+"/guilds/"+this.snowflake+"roles",{ + const fetched=await fetch(this.info.api+"/guilds/"+this.snowflake+"roles",{ method:"POST", headers:this.headers, body:JSON.stringify({ @@ -526,7 +526,7 @@ class Guild{ role.permissions.allow=perms.allow; role.permissions.deny=perms.deny; - await fetch(this.info.api.toString()+"/guilds/"+this.snowflake+"/roles/"+this.snowflake,{ + await fetch(this.info.api+"/guilds/"+this.snowflake+"/roles/"+this.snowflake,{ method:"PATCH", headers:this.headers, body:JSON.stringify({ diff --git a/webpage/index.ts b/webpage/index.ts index e6694e8..5dda741 100644 --- a/webpage/index.ts +++ b/webpage/index.ts @@ -31,40 +31,30 @@ thisuser.initwebsocket().then(_=>{ const userinfo=document.getElementById("userinfo"); const userdock=document.getElementById("userdock"); userinfo.addEventListener("click",function(event){ - const table=document.createElement("table"); + const table=document.createElement("div"); for(const thing of Object.values(users.users)){ const specialuser=thing as Specialuser; console.log(specialuser.pfpsrc) - const tr=document.createElement("tr"); - const td=document.createElement("td"); - const userinfo=document.createElement("table"); - userinfo.classList.add("switchtable"); - const row=document.createElement("tr"); - userinfo.append(row) - const pfpcell=document.createElement("td"); - row.append(pfpcell); + const userinfo=document.createElement("div"); + userinfo.classList.add("flexltr","switchtable"); const pfp=document.createElement("img"); - pfpcell.append(pfp); + userinfo.append(pfp); - const usertd=document.createElement("td") - row.append(usertd); const user=document.createElement("div"); - usertd.append(user); + userinfo.append(user); user.append(specialuser.username); user.append(document.createElement("br")); const span=document.createElement("span"); - span.textContent=specialuser.serverurls.wellknown.hostname; + span.textContent=specialuser.serverurls.wellknown.replace("https://","").replace("http://",""); user.append(span); + user.classList.add("userinfo") span.classList.add("serverURL") pfp.src=specialuser.pfpsrc; pfp.classList.add("pfp"); - td.append(userinfo) - - tr.append(td); - table.append(tr); - tr.addEventListener("click",_=>{ + table.append(userinfo); + userinfo.addEventListener("click",_=>{ thisuser.unload(); document.getElementById("loading").classList.remove("doneloading"); document.getElementById("loading").classList.add("loading"); @@ -82,14 +72,13 @@ thisuser.initwebsocket().then(_=>{ }) } { - const tr=document.createElement("tr"); - const td=document.createElement("td"); - tr.append(td); + const td=document.createElement("div"); + td.classList.add("switchtable") td.append("Switch accounts ⇌"); td.addEventListener("click",_=>{ window.location.href="/login.html"; }) - table.append(tr); + table.append(td); } table.classList.add("accountSwitcher"); if(Contextmenu.currentmenu!=""){ @@ -97,7 +86,7 @@ thisuser.initwebsocket().then(_=>{ } Contextmenu.currentmenu=table; console.log(table); - userdock.before(table); + document.body.append(table); event.stopImmediatePropagation(); }) } diff --git a/webpage/localuser.ts b/webpage/localuser.ts index e3bad05..44f56fd 100644 --- a/webpage/localuser.ts +++ b/webpage/localuser.ts @@ -18,9 +18,9 @@ class Localuser{ lastSequence:number|null=null; token:string; userinfo:Specialuser; - serverurls; + serverurls:Specialuser["serverurls"]; initialized:boolean; - info; + info:Specialuser["serverurls"]; headers:{"Content-type":string,Authorization:string}; usersettings:Settings; userConnections:Fullscreen; @@ -487,7 +487,7 @@ class Localuser{ }else{ parsed=inviteurl; } - fetch(this.info.api.toString()+"/v9/invites/"+parsed,{ + fetch(this.info.api+"/v9/invites/"+parsed,{ method:"POST", headers:this.headers, }).then(r=>r.json()).then(_=>{ @@ -512,7 +512,7 @@ class Localuser{ const full=new Fullscreen(["html", content]); full.show(); - const res=await fetch(this.info.api.toString()+"/v9/discoverable-guilds?limit=50", { + const res=await fetch(this.info.api+"/v9/discoverable-guilds?limit=50", { headers: this.headers }); const json=await res.json(); @@ -533,7 +533,7 @@ class Localuser{ const banner=document.createElement("img"); banner.classList.add("banner"); banner.crossOrigin="anonymous"; - banner.src=this.info.cdn.toString()+"icons/"+guild.id+"/"+guild.banner+".png?size=256"; + banner.src=this.info.cdn+"icons/"+guild.id+"/"+guild.banner+".png?size=256"; banner.alt=""; content.appendChild(banner); } @@ -543,7 +543,7 @@ class Localuser{ const img=document.createElement("img"); img.classList.add("icon"); img.crossOrigin="anonymous"; - img.src=this.info.cdn.toString()+(guild.icon ? ("/icons/"+guild.id+"/"+guild.icon+".png?size=48") : "/embed/avatars/3.png"); + img.src=this.info.cdn+(guild.icon ? ("/icons/"+guild.id+"/"+guild.icon+".png?size=48") : "/embed/avatars/3.png"); img.alt=""; nameContainer.appendChild(img); @@ -556,7 +556,7 @@ class Localuser{ content.appendChild(desc); content.addEventListener("click", async ()=>{ - const joinRes=await fetch(this.info.api.toString()+"/v9/guilds/"+guild.id+"/members/@me", { + const joinRes=await fetch(this.info.api+"/v9/guilds/"+guild.id+"/members/@me", { method: "PUT", headers: this.headers }); @@ -611,7 +611,7 @@ class Localuser{ var reader = new FileReader(); reader.readAsDataURL(file); reader.onload = ()=>{ - fetch(this.info.api.toString()+"/users/@me",{ + fetch(this.info.api+"/users/@me",{ method:"PATCH", headers:this.headers, body:JSON.stringify({ @@ -622,7 +622,7 @@ class Localuser{ } updatepronouns(pronouns:string):void{ - fetch(this.info.api.toString()+"/users/@me/profile",{ + fetch(this.info.api+"/users/@me/profile",{ method:"PATCH", headers:this.headers, body:JSON.stringify({ @@ -631,7 +631,7 @@ class Localuser{ }); } updatebio(bio:string):void{ - fetch(this.info.api.toString()+"/v9/users/@me/profile",{ + fetch(this.info.api+"/v9/users/@me/profile",{ method:"PATCH", headers:this.headers, body:JSON.stringify({ @@ -755,7 +755,7 @@ class Localuser{ const security=settings.addButton("Account Security"); if(this.mfa_enabled){ security.addTextInput("Disable 2FA, totp code:",_=>{ - fetch(this.info.api.toString()+"/users/@me/mfa/totp/disable",{ + fetch(this.info.api+"/users/@me/mfa/totp/disable",{ method:"POST", headers:this.headers, body:JSON.stringify({ @@ -786,7 +786,7 @@ class Localuser{ ["textbox","Account password:","",function(){password=this.value}], ["textbox","Code:","",function(){code=this.value}], ["button","","Submit",()=>{ - fetch(this.info.api.toString()+"/users/@me/mfa/totp/enable/",{ + fetch(this.info.api+"/users/@me/mfa/totp/enable/",{ method:"POST", headers:this.headers, body:JSON.stringify({ @@ -826,7 +826,7 @@ class Localuser{ ], () => {}, async () => { connectionContainer.innerHTML=""; - const res=await fetch(this.info.api.toString()+"/v9/connections", { + const res=await fetch(this.info.api+"/v9/connections", { headers: this.headers }); const json=await res.json(); @@ -839,7 +839,7 @@ class Localuser{ if (connection.enabled) { container.addEventListener("click", async () => { - const connectionRes=await fetch(this.info.api.toString()+"/v9/connections/" + key + "/authorize", { + const connectionRes=await fetch(this.info.api+"/v9/connections/" + key + "/authorize", { headers: this.headers }); const connectionJSON=await connectionRes.json(); @@ -870,7 +870,7 @@ class Localuser{ async () => { if (appName.trim().length == 0) return alert("Please enter a name for the application."); - const res=await fetch(this.info.api.toString()+"/v9/applications", { + const res=await fetch(this.info.api+"/v9/applications", { method: "POST", headers: this.headers, body: JSON.stringify({ @@ -889,7 +889,7 @@ class Localuser{ ], () => {}, async () => { appListContainer.innerHTML=""; - const res=await fetch(this.info.api.toString()+"/v9/applications", { + const res=await fetch(this.info.api+"/v9/applications", { headers: this.headers }); const json=await res.json(); @@ -900,7 +900,7 @@ class Localuser{ if (application.cover_image) { const cover=document.createElement("img"); cover.crossOrigin="anonymous"; - cover.src=this.info.cdn.toString()+"/app-icons/" + application.id + "/" + application.cover_image + ".png?size=256"; + cover.src=this.info.cdn+"/app-icons/" + application.id + "/" + application.cover_image + ".png?size=256"; cover.alt=""; cover.loading="lazy"; container.appendChild(cover); @@ -920,7 +920,7 @@ class Localuser{ ) } async manageApplication(appId="") { - const res=await fetch(this.info.api.toString()+"/v9/applications/" + appId, { + const res=await fetch(this.info.api+"/v9/applications/" + appId, { headers: this.headers }); const json=await res.json(); @@ -939,7 +939,7 @@ class Localuser{ fields.description=event.target.value; }], ["vdiv", - json.icon ? ["img", this.info.cdn.toString()+"/app-icons/" + appId + "/" + json.icon + ".png?size=128", [128, 128]] : ["text", "No icon"], + json.icon ? ["img", this.info.cdn+"/app-icons/" + appId + "/" + json.icon + ".png?size=128", [128, 128]] : ["text", "No icon"], ["fileupload", "Application icon:", event => { const reader=new FileReader(); reader.readAsDataURL(event.target.files[0]); @@ -970,7 +970,7 @@ class Localuser{ "", "Save changes", async () => { - const updateRes=await fetch(this.info.api.toString()+"/v9/applications/" + appId, { + const updateRes=await fetch(this.info.api+"/v9/applications/" + appId, { method: "PATCH", headers: this.headers, body: JSON.stringify(fields) @@ -989,7 +989,7 @@ class Localuser{ if (!json.bot) { if (!confirm("Are you sure you want to add a bot to this application? There's no going back.")) return; - const updateRes=await fetch(this.info.api.toString()+"/v9/applications/" + appId + "/bot", { + const updateRes=await fetch(this.info.api+"/v9/applications/" + appId + "/bot", { method: "POST", headers: this.headers }); @@ -1007,7 +1007,7 @@ class Localuser{ appDialog.show(); } async manageBot(appId="") { - const res=await fetch(this.info.api.toString()+"/v9/applications/" + appId, { + const res=await fetch(this.info.api+"/v9/applications/" + appId, { headers: this.headers }); const json=await res.json(); @@ -1015,7 +1015,7 @@ class Localuser{ const fields: any={ username: json.bot.username, - avatar: json.bot.avatar ? (this.info.cdn.toString()+"/app-icons/" + appId + "/" + json.bot.avatar + ".png?size=256") : "" + avatar: json.bot.avatar ? (this.info.cdn+"/app-icons/" + appId + "/" + json.bot.avatar + ".png?size=256") : "" }; const botDialog=new Fullscreen( ["vdiv", @@ -1042,7 +1042,7 @@ class Localuser{ "", "Save changes", async () => { - const updateRes=await fetch(this.info.api.toString()+"/v9/applications/" + appId + "/bot", { + const updateRes=await fetch(this.info.api+"/v9/applications/" + appId + "/bot", { method: "PATCH", headers: this.headers, body: JSON.stringify(fields) @@ -1060,7 +1060,7 @@ class Localuser{ async () => { if (!confirm("Are you sure you want to reset the bot token? Your bot will stop working until you update it.")) return; - const updateRes=await fetch(this.info.api.toString()+"/v9/applications/" + appId + "/bot/reset", { + const updateRes=await fetch(this.info.api+"/v9/applications/" + appId + "/bot/reset", { method: "POST", headers: this.headers }); diff --git a/webpage/login.ts b/webpage/login.ts index 865c8f7..860b027 100644 --- a/webpage/login.ts +++ b/webpage/login.ts @@ -57,7 +57,7 @@ function setDefaults(){ } setDefaults(); class Specialuser{ - serverurls; + serverurls:{api:string,cdn:string,gateway:string,wellknown:string,login:string}; email:string; token:string; loggedin; @@ -67,10 +67,13 @@ class Specialuser{ console.error("specialuser can't construct from another specialuser"); } this.serverurls=json.serverurls; - this.serverurls.api=new URL(this.serverurls.api); - this.serverurls.cdn=new URL(this.serverurls.cdn); - this.serverurls.gateway=new URL(this.serverurls.gateway); - this.serverurls.wellknown=new URL(this.serverurls.wellknown); + let apistring=new URL(json.serverurls.api).toString(); + apistring=apistring.replace(/\/(v\d+\/?)?$/, "")+"/v9"; + this.serverurls.api=apistring; + this.serverurls.cdn=new URL(json.serverurls.cdn).toString().replace(/\/$/,""); + this.serverurls.gateway=new URL(json.serverurls.gateway).toString().replace(/\/$/,"");; + this.serverurls.wellknown=new URL(json.serverurls.wellknown).toString().replace(/\/$/,"");; + this.serverurls.login=new URL(json.serverurls.login).toString().replace(/\/$/,"");; this.email=json.email; this.token=json.token; this.loggedin=json.loggedin; diff --git a/webpage/markdown.ts b/webpage/markdown.ts index e2af933..58087e1 100644 --- a/webpage/markdown.ts +++ b/webpage/markdown.ts @@ -421,7 +421,7 @@ class MarkDown{ emojiElem.classList.add("md-emoji"); emojiElem.classList.add(isEmojiOnly ? "bigemoji" : "smallemoji"); emojiElem.crossOrigin="anonymous"; - emojiElem.src=this.info.cdn.toString() + "emojis/" + parts[2] + "." + (parts[1] ? "gif" : "png") + "?size=32"; + emojiElem.src=this.info.cdn + "emojis/" + parts[2] + "." + (parts[1] ? "gif" : "png") + "?size=32"; emojiElem.alt=buildjoin; emojiElem.loading="lazy"; diff --git a/webpage/member.ts b/webpage/member.ts index b8bc16e..17a9e43 100644 --- a/webpage/member.ts +++ b/webpage/member.ts @@ -18,7 +18,7 @@ class Member{ navigator.clipboard.writeText(this.id); }); this.contextmenu.addbutton("Message user",function(){ - fetch(this.info.api.toString()+"/v9/users/@me/channels", + fetch(this.info.api+"/v9/users/@me/channels", {method:"POST", body:JSON.stringify({"recipients":[this.id]}), headers: this.headers diff --git a/webpage/message.ts b/webpage/message.ts index 5ab9df0..334c1f6 100644 --- a/webpage/message.ts +++ b/webpage/message.ts @@ -86,7 +86,7 @@ class Message{ break; } } - fetch(this.info.api.toString()+ "/channels/"+this.channel.id+"/messages/"+this.id+"/reactions/"+encodeURIComponent(emoji)+"/@me",{ + fetch(this.info.api+ "/channels/"+this.channel.id+"/messages/"+this.id+"/reactions/"+encodeURIComponent(emoji)+"/@me",{ method:remove?"DELETE":"PUT", headers:this.headers, }) @@ -186,14 +186,14 @@ class Message{ return build; } async edit(content){ - return await fetch(this.info.api.toString()+"/channels/"+this.channel.snowflake+"/messages/"+this.id,{ + return await fetch(this.info.api+"/channels/"+this.channel.snowflake+"/messages/"+this.id,{ method: "PATCH", headers: this.headers, body:JSON.stringify({content:content}) }); } delete(){ - fetch(`${this.info.api.toString()}/channels/${this.channel.snowflake}/messages/${this.id}`,{ + fetch(`${this.info.api}/channels/${this.channel.snowflake}/messages/${this.id}`,{ headers:this.headers, method:"DELETE", }) diff --git a/webpage/style.css b/webpage/style.css index 5fa742e..9980556 100644 --- a/webpage/style.css +++ b/webpage/style.css @@ -1044,20 +1044,28 @@ span { .accountSwitcher{ background:var(--profile-bg); cursor:pointer; - box-shadow: .00in -.5in 1in color-mix(in srgb, var(--shadow) 42%, transparent); - border-radius: .05in .05in .0in.0in; - flex-grow: 0; - align-self: center; - flex-shrink: 1; + box-shadow: .00in -.5in 2in color-mix(in srgb, var(--shadow) 42%, transparent); + border-radius: .1in; min-width: 0px; - display: inline-block; - width: 100%; - padding-left:.025in; + width: 80vw; + display: flex; + flex-direction: column; + padding: .1in; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + max-height: 80vh; + overflow: auto; + border:solid var(--black) .035in; } -.accountSwitcher tr{ +.switchtable{ transition: background .3s; background:var(--profile-bg); } +.switchtable:hover{ + background:var(--profile-info-bg); +} .accountSwitcher tr:hover{ background:var(--profile-info-bg); } @@ -1636,3 +1644,18 @@ form div{ .dontshrink{ flex-shrink:0; } +.switchtable{ + flex-grow:1; + flex-shrink: 0; + padding: .05in; + border-radius: .1in; + margin-bottom: .05in; + background: var(--message-bg-hover); + border: solid var(--black) .03in; + box-shadow: .01in .01in .05in var(--black); + align-items: center; +} +.userinfo{ + margin-left:.1in; + height:fit-content; +} \ No newline at end of file diff --git a/webpage/user.ts b/webpage/user.ts index d9e1611..f2bdd8c 100644 --- a/webpage/user.ts +++ b/webpage/user.ts @@ -52,7 +52,7 @@ class User{ navigator.clipboard.writeText(this.id.id); }); this.contextmenu.addbutton("Message user",function(){ - fetch(this.info.api.toString()+"/v9/users/@me/channels", + fetch(this.info.api+"/v9/users/@me/channels", {method:"POST", body:JSON.stringify({"recipients":[this.id.id]}), headers: this.localuser.headers @@ -144,9 +144,9 @@ class User{ return this.avatar; } if(this.avatar!=null){ - return this.info.cdn.toString()+"/avatars/"+this.id+"/"+this.avatar+".png"; + return this.info.cdn+"/avatars/"+this.id+"/"+this.avatar+".png"; }else{ - return this.info.cdn.toString()+"/embed/avatars/3.png"; + return this.info.cdn+"/embed/avatars/3.png"; } } createjankpromises(){