Skip to content

Commit

Permalink
1.1.0: Repairs, changes
Browse files Browse the repository at this point in the history
- Repaired discord token getting
- Repaired element styles
- Repaired images in readme.md
- Put many styles inline instead of relying on discord
  • Loading branch information
woodendoors7 committed Jun 5, 2024
1 parent 95bd5ca commit 98055f9
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 34 deletions.
12 changes: 6 additions & 6 deletions README.md

Large diffs are not rendered by default.

Binary file added docs/invites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/lonelydiscordfriendinvites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/newimage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
139 changes: 112 additions & 27 deletions inject.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
/*
DiscordFriendInvites 1.0.0
DiscordFriendInvites 1.1.0
by woodendoors7
*/


var html = `
<div id="mainWindow">
<div id="header">DiscordFriendInvites<br>by woodendoors7<div id="closeBtn" class="closeButton-30b1gR" aria-label="Dismiss" role="button" tabindex="0"><svg aria-hidden="true" role="img" class="closeIcon-3eoP1e" width="18" height="18" viewBox="0 0 24 24"><path fill="currentColor" d="M18.4 4L12 10.4L5.6 4L4 5.6L10.4 12L4 18.4L5.6 20L12 13.6L18.4 20L20 18.4L13.6 12L20 5.6L18.4 4Z"></path></svg></div></div>
<div id="header"><div id="closeBtn" aria-label="Dismiss" role="button" tabindex="0"><svg aria-hidden="true" role="img" width="18" height="18" viewBox="0 0 24 24"><path fill="currentColor" d="M18.4 4L12 10.4L5.6 4L4 5.6L10.4 12L4 18.4L5.6 20L12 13.6L18.4 20L20 18.4L13.6 12L20 5.6L18.4 4Z"></path></svg></div>DiscordFriendInvites<br>by woodendoors7<br></div>
<div class="toDisable">
<div class="dividing">
<p class="sectionTitle">
Create Invite
</p>
<button class="fieldButton-14lHvK button-ejjZWC lookFilled-1H2Jvj colorPrimary-2-Lusz sizeSmall-3R2P2p grow-2T4nbg" id="runCreate">Do It</button>
<button class="sectionButton" id="runCreate">Do It</button>
</div>
<div class="dividing">
Expand All @@ -22,32 +23,51 @@ var html = `
</select>
<button class="sectionButton fieldButton-14lHvK button-ejjZWC lookFilled-1H2Jvj colorPrimary-2-Lusz sizeSmall-3R2P2p grow-2T4nbg" id="runInfo">View Info</button>
<button class="sectionButton" id="runInfo">View Info</button>
</div>
<div onClick="this.select();" disabled type="text" class="textOutput inputDefault-Ciwd-S input-3O04eu" id="outputCreate"><b style="margin-top: 8px;display: block;">Welcome!</b></div>
<button style="margin-left: 32%; margin-top: 10px;" class="sectionButton fieldButton-14lHvK button-ejjZWC lookFilled-1H2Jvj colorPrimary-2-Lusz sizeSmall-3R2P2p grow-2T4nbg" id="runDelete">Delete All Invites</button>
<a href="https://github.com/woodendoors7/DiscordFriendInvites"><img style="margin-top: 10px; width: 250px;" src="https://cdn.discordapp.com/attachments/1113574795540430969/1113574807611650128/pleasestar.png"></a>
</div>
<div onClick="this.select();" disabled type="text" class="textOutput" id="outputCreate"><b style="margin-top: 5px; margin-bottom:5px; display: block;">Welcome!</b></div>
<div class="toDisable" id="reappear">
<button style="margin-left: 32%; margin-top: 10px;" class="sectionButton" id="runDelete">Delete All Invites</button>
</div>
<a href="https://github.com/woodendoors7/DiscordFriendInvites" target="_blank"><img style="margin-top: 10px; width: 250px;" src="https://images-ext-1.discordapp.net/external/2ISttgvfeo5oa4XaRdSTZJoo6F1Z3UqpRFiWCugQQJs/https/papers.floppa.hair/mcstatuspinger/pleasestar.png"></a>
</div>`

var css = `#mainWindow {
var css = `
#mainWindow {
position: absolute;
z-index: 9;
background-color: #2F3136;
border: 1px solid #3f4147;
color: white;
text-align: center;
height: 280px;
height: 270px;
width: 400px;
font-family: "Century Gothic", CenturyGothic, Geneva, AppleGothic, sans-serif;
z-index: 1000;
border-radius: 12px;
font-family: var(--font-primary);
}
#reappear{
display: none;
}
#closeBtn{
width: 30px;
cursor: pointer !important;
float:right;
}
.toDisable{
opacity:0.4;
pointer-events: none;
}
#header {
padding: 10px;
cursor: move;
z-index: 10;
background-color: #5865F2;
background-color: #5865f2;
color: #ffe8e9;
user-select: none;
font-weight: bold;
Expand Down Expand Up @@ -75,8 +95,38 @@ var css = `#mainWindow {
.sectionButton {
vertical-align: middle;
margin-top: auto;
margin-bottom: auto;
position: relative;
display: flex;
justify-content: center;
align-items: center;
box-sizing: border-box;
background: none;
border: none;
border-radius: 3px;
font-size: 14px;
font-weight: 500;
line-height: 16px;
padding: 2px 16px;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
transition: background-color 170ms ease,color 170ms ease;
color: var(--white-500);
background-color: var(--button-secondary-background);
width: var(--custom-button-button-sm-width);
height: var(--custom-button-button-sm-height);
min-width: var(--custom-button-button-sm-width);
min-height: var(--custom-button-button-sm-height);
width: auto !important;
}
.sectionButton:hover{
background-color: var(--button-secondary-background-hover);
color: var(--white-500);
}
.dividing * {
display: inline;
}
Expand All @@ -90,9 +140,9 @@ var css = `#mainWindow {
padding: 3px;
text-align: center;
margin-left: 10px;
background-color: #1e1f22;
}`


if (document.readyState === "complete") {
inject()
}
Expand All @@ -104,7 +154,7 @@ var div;
var closeBtn;

async function inject() {
var doThis = document.createElement("div")
let doThis = document.createElement("div")
doThis.innerHTML = html;
doThis.innerHTML += `\n\n<style>${css}</style>`
document.body.appendChild(doThis)
Expand Down Expand Up @@ -132,15 +182,26 @@ async function inject() {

closeBtn.addEventListener("click", uninject)

token = await getToken()
outputCreate.innerHTML = `<b style="margin-top: 8px;display: block;">Welcome!</b>`
fetchInvites(false)
token = await getToken();
console.log("Got token!")
document.querySelector("#reappear").style = "display:block;"

let enableIt = document.querySelectorAll('.toDisable');

enableIt.forEach(element => {
element.style.opacity = "1"
element.style.pointerEvents = "auto"
});

outputCreate.innerHTML = `<b style="margin-top: 5px; margin-bottom: 5px; display: block;">Welcome!</b>`

fetchInvites(false);
}



async function createElement() {
outputCreate.innerHTML = `<b style="margin-top: 8px;display: block;">Loading . . .</b>`
outputCreate.innerHTML = `<b style="margin-top: 5px;display: block;">Loading . . .</b>`
let result = await fetch("https://discord.com/api/v9/users/@me/invites", {
"credentials": "include",
"headers": {
Expand All @@ -164,8 +225,8 @@ async function createElement() {
});

let resultParsed = await result.json();

outputCreate.innerHTML = `<b style="margin-top: 8px;display: block;">https://discord.gg/${resultParsed.code}</b>`
console.log(resultParsed)
outputCreate.innerHTML = `<b style="margin-top: 5px; margin-bottom: 5px; display: block;">https://discord.gg/${resultParsed.code}</b>`

if (selectInvite.firstChild.innerText == "No Invites") {
selectInvite.innerHTML = ``;
Expand Down Expand Up @@ -221,7 +282,7 @@ async function fetchInvites(returnTrue) {

async function checkTheInfo() {
let value = selectInvite.value;
outputCreate.innerHTML = `<b style="margin-top: 8px;display: block;">Loading . . .</b>`
outputCreate.innerHTML = `<b style="margin-top: 5px; margin-bottom: 5px; display: block;">Loading . . .</b>`
let result = await fetchInvites(true)
let thing;
for (let count = 0; count < result.length; count++) {
Expand All @@ -237,7 +298,7 @@ async function checkTheInfo() {
}

async function deleteInvites() {
let result = await fetch("https://discord.com/api/v9/users/@me/invites", {
await fetch("https://discord.com/api/v9/users/@me/invites", {
"credentials": "include",
"headers": {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; rv:103.0) Gecko/20100101 Firefox/103.0",
Expand All @@ -262,7 +323,7 @@ async function deleteInvites() {
choice.value = "none";
choice.innerText = "No Invites";
selectInvite.appendChild(choice)
outputCreate.innerHTML = `<b style="margin-top: 8px;display: block;">Invites deleted</b>`
outputCreate.innerHTML = `<b style="margin-top: 5px; margin-bottom: 5px; display: block;">Invites deleted</b>`
}

var offsetLeft;
Expand All @@ -286,12 +347,36 @@ function divMove(e) {
div.style.left = (e.clientX + offsetLeft) + 'px';
}



async function getToken() {
outputCreate.innerHTML = `<b style="margin-top: 8px;display: block;">Getting token...</b>`
return await (webpackChunkdiscord_app.push([[''], {}, e => { m = []; for (let c in e.c) m.push(e.c[c]) }]), m).find(m => m?.exports?.default?.getToken !== void 0).exports.default.getToken()
return new Promise(function (resolve) {
outputCreate.innerHTML = `<b style="margin-top: 5px; margin-bottom: 5px; display: block;">Getting token...</b><p>Please, switch to a random channel on Discord to obtain token!</p>`
outputCreate.innerHTML = `<div style="margin-top: 10px; margin-bottom: 10px;"><b>Getting token...</b></br> <i>Please, switch to a random channel on Discord to obtain token!</i></div>`

// New token script, a request interceptor, courtesy of Caltrop256
window.__request = window.XMLHttpRequest;
window.XMLHttpRequest = class __Interceptor extends window.__request {
constructor() {
super(...arguments);
this._reqHead = this.setRequestHeader;
this.setRequestHeader = function (name, body) {
this._reqHead(name, body);
if (name === "Authorization") {
window.XMLHttpRequest = window.__request;

resolve(body);
}
}.bind(this);
};

}
})
}

async function uninject() {
window.XMLHttpRequest = window.__request;


window.removeEventListener('mousemove');
document.getElementById('header').removeEventListener('mousedown')
Expand All @@ -304,7 +389,7 @@ async function uninject() {
checkTheInfo = null;
deleteInvites = null;
removeEventListener("mouseMove", window)

console.log("Goodbye!")
}


Expand Down
Loading

0 comments on commit 98055f9

Please sign in to comment.