From 935c45236bde55f9e209feb9ea79d7b967b37f81 Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:20:24 -0400 Subject: [PATCH 01/19] Create clubs.json --- config/clubs.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 config/clubs.json diff --git a/config/clubs.json b/config/clubs.json new file mode 100644 index 0000000..efe2c8e --- /dev/null +++ b/config/clubs.json @@ -0,0 +1,6 @@ +{ +"club Name": "clubData", +"Another Club": "clubData", +"Emoji Club 💔": "clubData", +"etc": "clubData" +} From c748e74c0902b81f50b3705994b67b54aca5432d Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:21:06 -0400 Subject: [PATCH 02/19] Update index.css --- src/css/index.css | 49 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/src/css/index.css b/src/css/index.css index dbc2523..6fbc6d5 100644 --- a/src/css/index.css +++ b/src/css/index.css @@ -11,7 +11,7 @@ body { } .sidebarcomp { text-align: center; - margin-top: 1.8em; + margin-top: 0em; display: block; -webkit-app-region: no-drag; } @@ -36,6 +36,7 @@ h3 { border-width: thin; color: white; cursor: pointer; + font-size: 23px; } .barMouseOver { transition: border 500ms, color 500ms; @@ -179,11 +180,14 @@ img { .clubPage { text-align: center; } -#clubs { +.clubs { font-size: 1.5em; - margin-top: 5em; + margin-top: 1em; cursor: pointer; } +.bottomClubs{ + margin-top: 1em !important; +} #setClub { padding: 0; font-size: 1.7em; @@ -283,8 +287,8 @@ img { text-align: center; color: white; font-size: 30px; - line-height: 20px; - margin-top: 50px; + line-height: 25px; + margin-top: 30px; } .iconButtons { display: inline-block; @@ -310,3 +314,38 @@ dd{ -webkit-text-stroke-width: 0.7px; -webkit-text-stroke-color: white; } +.customContent{ + text-align: center; +} +#endPoint{ + cursor: text; + font-size: 20px; +} +#method{ + font-size: 18px; + cursor: pointer; +} +#requestBody{ + font-size: 32px; + cursor: text; +} +#response{ + font-size: 32px; + overflow:hidden; +} +#requestLCU{ + padding: 0; + font-size: 1.5em; + width: 5.5em; + height: 30px; + padding-bottom: 1px; + cursor: pointer; +} +#lcuEndpoints{ + padding: 0; + font-size: 1.5em; + width: 6em; + height: 30px; + padding-bottom: 1px; + cursor: pointer; +} From 2300667a05d1b0bb0e1a9a1cf55cbd9c7c30f02a Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:21:52 -0400 Subject: [PATCH 03/19] Update club.html --- src/html/club.html | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/src/html/club.html b/src/html/club.html index 20c50d8..b7bb51e 100644 --- a/src/html/club.html +++ b/src/html/club.html @@ -17,35 +17,7 @@

*You must also be in a club first*

onchange="this.size=1; this.blur();" > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
From b53e4fb9c74a01159ee8b431672bff2a9dc67521 Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:22:32 -0400 Subject: [PATCH 04/19] Update club.html --- src/html/club.html | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/html/club.html b/src/html/club.html index b7bb51e..8c1650c 100644 --- a/src/html/club.html +++ b/src/html/club.html @@ -9,9 +9,11 @@

*And Restart This Program*

*You must also be in a club first*

+

*User Clubs is located in config/clubs.json*

+
+ +
Date: Sun, 23 Aug 2020 22:23:02 -0400 Subject: [PATCH 05/19] Create custom.html --- src/html/custom.html | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/html/custom.html diff --git a/src/html/custom.html b/src/html/custom.html new file mode 100644 index 0000000..9927117 --- /dev/null +++ b/src/html/custom.html @@ -0,0 +1,36 @@ + + + +
+
+
+ + +
+ +

Request Body (For POST and PUT)

+ + + +

Response

+ +
+ + From f8e5a51f3c8950d4d255727be2a089867c0b4479 Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:23:23 -0400 Subject: [PATCH 06/19] Update home.html --- src/html/home.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/html/home.html b/src/html/home.html index 3677617..685c84f 100644 --- a/src/html/home.html +++ b/src/html/home.html @@ -3,7 +3,7 @@

LEAGUE PROFILE TOOL

-

Local Version: V.2.4.4

+

Local Version: V.2.4.5

Check github for discord

From 11c5e2c8575dfefe52661c836a81ca8be5008bd6 Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:23:44 -0400 Subject: [PATCH 07/19] Update icon.html --- src/html/icon.html | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/html/icon.html b/src/html/icon.html index fa72135..ba32bba 100644 --- a/src/html/icon.html +++ b/src/html/icon.html @@ -218,8 +218,7 @@ height="100" />

- Any icon code, the icon shows to everyone
on the client (you will not see it)
however it - goes away when you log out! + The custom icon goes away when you log out!

@@ -232,8 +231,12 @@

- - + +
From 1acf3baf2409364d94155de2aa0ce720b89dbd2a Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:24:04 -0400 Subject: [PATCH 08/19] Update index.html --- src/index.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/index.html b/src/index.html index f5dc70a..3e498c7 100644 --- a/src/index.html +++ b/src/index.html @@ -36,6 +36,9 @@

Club Tag

Aram

+
+

Custom Request

+

F.A.Q

From e23f6b6329b3b04a38b2810a0254e0326ba88045 Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:24:46 -0400 Subject: [PATCH 09/19] Update index.js --- src/index.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 6d51d41..f8f58ef 100644 --- a/src/index.js +++ b/src/index.js @@ -2,6 +2,7 @@ const { app, BrowserWindow, dialog, globalShortcut } = require("electron"); const path = require("path"); const exec = require("child_process").exec; let pathSpecified = false; + // Check if the user is logged into the league client const isRunning = (query, cb) => { let platform = process.platform; @@ -23,12 +24,14 @@ const isRunning = (query, cb) => { cb(stdout.toLowerCase().indexOf(query.toLowerCase()) > -1); }); }; + +// Check if clientPath file contains the client path or if the file is corrupted try { const fs = require("fs"); - const clientPath = fs.readFileSync('config\\clientPath.txt').toString(); + const clientPath = fs.readFileSync("config\\clientPath.txt").toString(); if (clientPath !== "") pathSpecified = true; } catch (err) { - dialog.showErrorBox("Error", 'The path file is corrupted'); + dialog.showErrorBox("Error", "The path file is corrupted"); } // status will be true or false isRunning("LeagueClient.exe", (status) => { @@ -86,4 +89,4 @@ app.on("activate", () => { if (BrowserWindow.getAllWindows().length === 0) { createWindow(); } -}); \ No newline at end of file +}); From c9489fd069dc4cedeab9c4829e431865d418fa3b Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:25:06 -0400 Subject: [PATCH 10/19] Update app.js --- src/javascript/app.js | 141 +++++++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 64 deletions(-) diff --git a/src/javascript/app.js b/src/javascript/app.js index 6b582c4..2167b32 100644 --- a/src/javascript/app.js +++ b/src/javascript/app.js @@ -6,14 +6,7 @@ const LCUConnector = require("lcu-connector"); const connector = new LCUConnector(); const request = require("request"); const exit = document.querySelector("#exit"); -var server = ""; -// For LCU connection -const options = { - rejectUnauthorized: false, - headers: { - Accept: "application/json", - }, -}; +var LeagueClient; /* Look if user has set the path to the client, if so use that path, @@ -26,23 +19,84 @@ try { connector._dirPath = file.split("\\").join("/"); } } catch (err) {} + +// Make a request to get the server and create a ClientConnection to make requests connector.on("connect", (data) => { - options["url"] = `${data["protocol"]}://${data["address"]}:${data["port"]}`; - options["headers"]["Authorization"] = - "Basic " + btoa(`${data["username"]}:${data["password"]}`); - optionsCopy = Object.assign({}, options); - optionsCopy["url"] = `${optionsCopy["url"]}/lol-chat/v1/me`; - optionsCopy["method"] = "GET"; - request(optionsCopy, function (error, response) { - var summoner = JSON.parse(response.body); - var summonerID = summoner.id; - server = summonerID.substring( - summonerID.indexOf("@") + 1, - summonerID.length - ); - server = server.substring(0, server.indexOf(".")); + let url = `${data["protocol"]}://${data["address"]}:${data["port"]}`; + let auth = "Basic " + btoa(`${data["username"]}:${data["password"]}`); + let options = { + rejectUnauthorized: false, + headers: { + Accept: "application/json", + Authorization: auth, + }, + url: `${url}/lol-chat/v1/me`, + method: "GET", + }; + request(options, function (error, response) { + if (!error) { + var summoner = JSON.parse(response.body); + var summonerID = summoner.id; + var server = summonerID.substring( + summonerID.indexOf("@") + 1, + summonerID.length + ); + server = server.substring(0, server.indexOf(".")); + LeagueClient = new ClientConnection(url, options, server); + } else { + dialog.showErrorBox("Error", `Could not set summoner server\n${error}`); + LeagueClient = new ClientConnection(url, options, ""); + } }); }); + +// Class to make requests to the client +class ClientConnection { + constructor(url, options, server) { + this.url = url; + this.options = options; + this.server = server; + } + makeRequest(method, body, endPoint) { + this.options["url"] = this.url + endPoint; + this.options["method"] = method; + this.options["body"] = JSON.stringify(body); + this.run(this.options); + } + run(command) { + request(command, function (error, response) { + let dialogOptions = {}; + if ( + !error && + (response.statusCode === 201 || + response.statusCode === 200 || + response.statusCode === 204) + ) { + dialogOptions = { + type: "info", + title: "Success", + message: "The request has been made", + }; + } else { + let status = "No response from LCU"; + try { + status = response.body; + } catch (e) {} + dialogOptions = { + type: "error", + title: "Error", + message: `There was an error: \n(${status})`, + }; + } + dialog.showMessageBox(dialogOptions); + }); + } + getServer() { + return this.server; + } +} + +// Close window when league client connection is lost connector.on("disconnect", (data) => { dialog.showErrorBox( "Error", @@ -97,9 +151,9 @@ function active() { if (this.readyState !== 4) return; if (this.status !== 200) return; document.querySelector(".pane").innerHTML = this.responseText; + loadjs(page); }; xhr.send(); - loadjs(page); } function loadjs(page) { const script = document.createElement("script"); @@ -108,44 +162,3 @@ function loadjs(page) { script.defer = true; document.body.appendChild(script); } - -// Function to make a request to the LCU api -function makeRequest(method, body, endPoint) { - const optionsCopy = Object.assign({}, options); - optionsCopy["url"] = `${optionsCopy["url"]}${endPoint}`; - optionsCopy["method"] = method; - optionsCopy["body"] = JSON.stringify(body); - run(optionsCopy); -} - -// Response after the request to the LCU api has been made -function callback(error, response) { - let dialogOptions = {}; - if ( - !error && - (response.statusCode === 201 || - response.statusCode === 200 || - response.statusCode === 204) - ) { - dialogOptions = { - type: "info", - title: "Success", - message: `The request has been made`, - }; - } else { - dialogOptions = { - type: "error", - title: "Error", - message: "There was an error", - }; - } - dialog.showMessageBox(dialogOptions); -} - -function run(command) { - request(command, callback); -} - -function getServer() { - return server; -} From 0c044f50b50ca41f7328314508566aefc4a7dd6c Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:25:26 -0400 Subject: [PATCH 11/19] Update aram.js --- src/javascript/aram.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/javascript/aram.js b/src/javascript/aram.js index 9fcc584..112484d 100644 --- a/src/javascript/aram.js +++ b/src/javascript/aram.js @@ -5,12 +5,16 @@ boost.addEventListener("mousedown", function () { type: "question", title: "Confirmation", message: - "Are you sure you want to continue? \n(Make sure you don't have enough RP for a boost)\nThis exploit can also be detected!", + "Are you sure you want to continue? \n(Make sure you don't have enough RP for a boost)\nThis exploit can also be detected!", buttons: ["Yes", "No"], }; dialog.showMessageBox(dialogOptions).then((response) => { if (response.response === 0) - makeRequest("POST", "", "/lol-champ-select/v1/team-boost/purchase"); + LeagueClient.makeRequest( + "POST", + "", + "/lol-champ-select/v1/team-boost/purchase" + ); }); }); From 2e03c7421f5e83a0a4a561bb3b8d793da6058f74 Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:25:41 -0400 Subject: [PATCH 12/19] Update background.js --- src/javascript/background.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/javascript/background.js b/src/javascript/background.js index 3ca6b7d..5b58b12 100644 --- a/src/javascript/background.js +++ b/src/javascript/background.js @@ -47,7 +47,7 @@ load().then(function () { }); node.addEventListener("mousedown", function () { iconCode["value"] = parseInt(this.alt); - makeRequest("POST", iconCode, "/lol-summoner/v1/current-summoner/summoner-profile") + LeagueClient.makeRequest("POST", iconCode, "/lol-summoner/v1/current-summoner/summoner-profile") }); champions.appendChild(node); } From 135fd5435591c93bba15dbd7c770ffe4fd5d2a5f Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:26:19 -0400 Subject: [PATCH 13/19] Update club.js --- src/javascript/club.js | 106 +++++++++++++++++++++++++++-------------- 1 file changed, 70 insertions(+), 36 deletions(-) diff --git a/src/javascript/club.js b/src/javascript/club.js index 42df39f..938bf29 100644 --- a/src/javascript/club.js +++ b/src/javascript/club.js @@ -1,10 +1,38 @@ -var club = document.getElementById("clubs"); +var club = document.querySelectorAll(".clubs"); var setClub = document.getElementById("setClub"); var clubCode = document.getElementById("clubCode"); var friendName = document.getElementById("friendName"); var lobbyMember = document.getElementById("lobbyMember"); var champSelectMem = document.getElementById("champSelect"); var getClubData = document.getElementById("getClubData"); +var customClubs = document.getElementById("customClubs"); +var fs = require("fs"); + +// Attempt to set any user set clubs in config/clubs.json +try { + const jsonString = fs.readFileSync("./config/clubs.json"); + const data = JSON.parse(jsonString); + Object.keys(data).forEach(function (key) { + var option = document.createElement("option"); + option.label = key; + option.text = key; + option.classList.add("club"); + option.value = data[key]; + customClubs.add(option); + }); +} catch (err) { + const dialogOptions = { + type: "error", + title: "Error", + message: `There was an error with custom user clubs (${err})\nPlease make sure config/clubs.json is in proper JSON format`, + buttons: ["Open Json Validator", "Ok"], + }; + dialog.showMessageBox(dialogOptions).then((response) => { + if (response.response === 0) + require("electron").shell.openExternal("https://jsonlint.com/"); + }); +} + var clubKeys = { }; @@ -13,23 +41,30 @@ var clubInfo = { clubsData: "", }, }; -club.addEventListener("focus", function () { - friendName.classList.add("clubCodeFocus"); -}); -club.addEventListener("blur", function () { - friendName.classList.remove("clubCodeFocus"); +for (var i = 0; i < club.length; i++) { + club[i].addEventListener("focus", function () { + friendName.classList.add("clubCodeFocus"); + }); + club[i].addEventListener("blur", function () { + friendName.classList.remove("clubCodeFocus"); + }); +} +club[0].addEventListener("change", function () { + clubInfo["lol"]["clubsData"] = clubKeys[this.value]; + LeagueClient.makeRequest("PUT", clubInfo, "/lol-chat/v1/me"); }); -club.addEventListener("change", function () { - clubInfo["lol"]["clubsData"] = clubKeys[club.value]; - makeRequest("PUT", clubInfo, "/lol-chat/v1/me"); +club[1].addEventListener("change", function () { + clubInfo["lol"]["clubsData"] = this.value; + LeagueClient.makeRequest("PUT", clubInfo, "/lol-chat/v1/me"); }); + setClub.addEventListener("mousedown", function () { getClub(true); }); -getClubData.addEventListener("mousedown", function(){ +getClubData.addEventListener("mousedown", function () { getClub(false); -}) -function getClub(sendRequest){ +}); +function getClub(sendRequest) { if ( clubCode.value === "" && friendName.value === "" && @@ -44,8 +79,8 @@ function getClub(sendRequest){ }; return dialog.showMessageBox(dialogOptions); } else if (friendName.value !== "") { - const optionsCopy = Object.assign({}, options); - optionsCopy["url"] = `${optionsCopy["url"]}/lol-chat/v1/friends`; + let optionsCopy = Object.assign({}, LeagueClient.options); + optionsCopy["url"] = LeagueClient.url + "/lol-chat/v1/friends"; optionsCopy["method"] = "GET"; request(optionsCopy, function (error, response) { if (response.statusCode !== 404) { @@ -70,11 +105,11 @@ function getClub(sendRequest){ message: "That friends club data could not be found", }; } else { - if (sendRequest){ + if (sendRequest) { clubInfo["lol"]["clubsData"] = friends[i].lol.clubsData; - makeRequest("PUT", clubInfo, "/lol-chat/v1/me"); + LeagueClient.makeRequest("PUT", clubInfo, "/lol-chat/v1/me"); } - return clubCode.value = friends[i].lol.clubsData; + return (clubCode.value = friends[i].lol.clubsData); } return dialog.showMessageBox(dialogOptions); } @@ -95,8 +130,8 @@ function getClub(sendRequest){ } }); } else if (champSelectMem.value !== "") { - var optionsCopy = Object.assign({}, options); - optionsCopy["url"] = `${optionsCopy["url"]}/lol-champ-select/v1/session`; + let optionsCopy = Object.assign({}, LeagueClient.options); + optionsCopy["url"] = LeagueClient.url + "/lol-champ-select/v1/session"; optionsCopy["method"] = "GET"; request(optionsCopy, function (error, response) { if (response.statusCode === 404) { @@ -109,15 +144,15 @@ function getClub(sendRequest){ } var champSelectLobby = JSON.parse(response.body); var lobbyID = champSelectLobby.chatDetails.chatRoomName; - var server = getServer(); + var server = LeagueClient.getServer(); var champSelectID = `${lobbyID.substring( 0, lobbyID.indexOf("@") )}@champ-select.${server}.pvp.net/participants`; - optionsCopy = Object.assign({}, options); + // optionsCopy = Object.assign({}, options); optionsCopy[ "url" - ] = `${optionsCopy["url"]}/lol-chat/v1/conversations/${champSelectID}`; + ] = `${LeagueClient.url}/lol-chat/v1/conversations/${champSelectID}`; optionsCopy["method"] = "GET"; request(optionsCopy, function (error, response) { if (response.statusCode === 404) { @@ -134,11 +169,11 @@ function getClub(sendRequest){ champSelectMem.value.toUpperCase() === summoners[i].name.toUpperCase() ) { - if (sendRequest){ + if (sendRequest) { clubInfo["lol"]["clubsData"] = summoners[i].lol.clubsData; - makeRequest("PUT", clubInfo, "/lol-chat/v1/me"); + LeagueClient.makeRequest("PUT", clubInfo, "/lol-chat/v1/me"); } - return clubCode.value = summoners[i].lol.clubsData; + return (clubCode.value = summoners[i].lol.clubsData); } } dialogOptions = { @@ -150,21 +185,20 @@ function getClub(sendRequest){ }); }); } else if (lobbyMember.value !== "") { - var optionsCopy = Object.assign({}, options); - optionsCopy["url"] = `${optionsCopy["url"]}/lol-lobby/v2/lobby`; + let optionsCopy = Object.assign({}, LeagueClient.options); + optionsCopy["url"] = LeagueClient.url + "/lol-lobby/v2/lobby"; optionsCopy["method"] = "GET"; request(optionsCopy, function (error, response) { if (response.statusCode !== 404) { var chat = JSON.parse(response.body); var ID = chat.chatRoomId; - var server = getServer(); + var server = LeagueClient.getServer(); var chatID = `${ID.substring( 0, ID.indexOf("@") )}@sec.${server}.pvp.net`; var lobby = `/lol-chat/v1/conversations/${chatID}/participants`; - optionsCopy = Object.assign({}, options); - optionsCopy["url"] = `${optionsCopy["url"]}${lobby}`; + optionsCopy["url"] = LeagueClient.url + lobby; optionsCopy["method"] = "GET"; request(optionsCopy, function (error, response) { var participants = JSON.parse(response.body); @@ -173,11 +207,11 @@ function getClub(sendRequest){ lobbyMember.value.toUpperCase() === participants[i].name.toUpperCase() ) { - if (sendRequest){ + if (sendRequest) { clubInfo["lol"]["clubsData"] = participants[i].lol.clubsData; - makeRequest("PUT", clubInfo, "/lol-chat/v1/me"); + LeagueClient.makeRequest("PUT", clubInfo, "/lol-chat/v1/me"); } - return clubCode.value = participants[i].lol.clubsData; + return (clubCode.value = participants[i].lol.clubsData); } } dialogOptions = { @@ -197,9 +231,9 @@ function getClub(sendRequest){ } }); } else { - if (sendRequest){ + if (sendRequest) { clubInfo["lol"]["clubsData"] = clubCode.value; - makeRequest("PUT", clubInfo, "/lol-chat/v1/me"); + LeagueClient.makeRequest("PUT", clubInfo, "/lol-chat/v1/me"); } } -} \ No newline at end of file +} From 520d6c05a8e01e89b11f3d78d0e91fa87e982070 Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:26:38 -0400 Subject: [PATCH 14/19] Update count.js --- src/javascript/count.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/javascript/count.js b/src/javascript/count.js index eb231cd..e01c5c1 100644 --- a/src/javascript/count.js +++ b/src/javascript/count.js @@ -1,6 +1,6 @@ var displayChampArea = document.querySelector(".ownedChamps"); -var optionsCopy = Object.assign({}, options); -optionsCopy["url"] = `${optionsCopy["url"]}/lol-summoner/v1/current-summoner`; +var optionsCopy = Object.assign({}, LeagueClient.options); +optionsCopy["url"] = LeagueClient.url + "/lol-summoner/v1/current-summoner"; optionsCopy["method"] = "GET"; var summonerID = 0; var version = 0; @@ -15,12 +15,12 @@ load().then(function () { if (!error && response.statusCode === 200) { summonerID = JSON.parse(body); summonerID = summonerID["summonerId"]; - let optionsCopy2 = Object.assign({}, options); - optionsCopy2[ + // let optionsCopy2 = Object.assign({}, options); + optionsCopy[ "url" - ] = `${optionsCopy2["url"]}/lol-champions/v1/inventories/${summonerID}/champions`; - optionsCopy2["method"] = "GET"; - getOwnedChampions(optionsCopy2); + ] = `${LeagueClient.url}/lol-champions/v1/inventories/${summonerID}/champions`; + optionsCopy["method"] = "GET"; + getOwnedChampions(optionsCopy); } else { dialog.showErrorBox( "Error", From f7b9488bcea845ebbc83f3338d1662ed3c77bc45 Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:27:01 -0400 Subject: [PATCH 15/19] Create custom.js --- src/javascript/custom.js | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/javascript/custom.js diff --git a/src/javascript/custom.js b/src/javascript/custom.js new file mode 100644 index 0000000..7bd14e5 --- /dev/null +++ b/src/javascript/custom.js @@ -0,0 +1,82 @@ +var endPoint = document.getElementById("endPoint"); +var method = document.getElementById("method"); +var requestBody = document.getElementById("requestBody"); +var requestLCU = document.getElementById("requestLCU"); +var reply = document.getElementById("response"); +var endpointList = document.getElementById("lcuEndpoints"); + +endpointList.addEventListener("mousedown", function () { + require("electron").shell.openExternal( + "http://www.mingweisamuel.com/lcu-schema/tool/" + ); +}); + +requestLCU.addEventListener("mousedown", function () { + if (endPoint.value === "") { + dialogOptions = { + type: "error", + title: "Error", + message: `Please enter in an endpoint`, + }; + return dialog.showMessageBox(dialogOptions); + } else if (method.value === "") { + dialogOptions = { + type: "error", + title: "Error", + message: `Please select a method`, + }; + return dialog.showMessageBox(dialogOptions); + } + try { + var body = JSON.parse(requestBody.value); + } catch (e) { + dialogOptions = { + type: "error", + title: "Error", + message: `Invalid JSON for request body`, + }; + return dialog.showMessageBox(dialogOptions); + } + sendRequest(method.value, body, endPoint.value); +}); + +reply.addEventListener("input", autoResize, false); + +function autoResize() { + this.style.height = "auto"; + this.style.height = this.scrollHeight + "px"; +} + +function sendRequest(method, body, endPoint) { + let optionsCopy = Object.assign({}, LeagueClient.options); + optionsCopy["url"] = LeagueClient.url + endPoint; + optionsCopy["method"] = method; + optionsCopy["body"] = JSON.stringify(body); + run(optionsCopy); +} + +function run(command) { + request(command, function (error, response) { + let dialogOptions = {}; + try { + dialogOptions = { + type: "info", + title: "Info", + message: `Response status code: ${response.statusCode}`, + }; + reply.value = ""; + var obj = JSON.parse(response.body); + var format = JSON.stringify(obj, null, 3); + reply.value = format; + input = new Event("input"); + reply.dispatchEvent(input); + } catch (e) { + dialogOptions = { + type: "info", + title: "Info", + message: "Made the request", + }; + } + dialog.showMessageBox(dialogOptions); + }); +} From b3e096bd6b9e741cd416d2e8fb6a4fe852eb3d1f Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:27:22 -0400 Subject: [PATCH 16/19] Update icon.js --- src/javascript/icon.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/javascript/icon.js b/src/javascript/icon.js index 8caf47c..a961b7f 100644 --- a/src/javascript/icon.js +++ b/src/javascript/icon.js @@ -17,14 +17,18 @@ for (let i = 0; i < imgButtons.length; i++) { }); imgButtons[i].addEventListener("mousedown", function () { iconCode["profileIconId"] = parseInt(this.alt); - makeRequest("PUT", iconCode, "/lol-summoner/v1/current-summoner/icon"); + LeagueClient.makeRequest( + "PUT", + iconCode, + "/lol-summoner/v1/current-summoner/icon" + ); }); } iconButton.addEventListener("mousedown", function () { let value = parseInt(text.value); if (!isNaN(value) && !(value < 0)) { anyIcon["icon"] = value; - makeRequest("PUT", anyIcon, "/lol-chat/v1/me"); + LeagueClient.makeRequest("PUT", anyIcon, "/lol-chat/v1/me"); } else { let dialogOptions = { type: "error", From 5f196fc02489dd029c11e8cd1b844b2905a42daf Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:27:36 -0400 Subject: [PATCH 17/19] Update rank.js --- src/javascript/rank.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/javascript/rank.js b/src/javascript/rank.js index 8bf7044..b353719 100644 --- a/src/javascript/rank.js +++ b/src/javascript/rank.js @@ -61,7 +61,7 @@ for (let i = 0; i < queue.length; i++) { node.addEventListener("mousedown", function () { rankInfo["lol"]["rankedLeagueTier"] = this.alt; rankInfo["lol"]["rankedLeagueDivision"] = this.id; - makeRequest("PUT", rankInfo, "/lol-chat/v1/me"); + LeagueClient.makeRequest("PUT", rankInfo, "/lol-chat/v1/me"); }); rankMain.appendChild(node); } From c5ccefa820e18d8a334df3077ea9d119e89f0839 Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:27:56 -0400 Subject: [PATCH 18/19] Update status.js --- src/javascript/status.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/javascript/status.js b/src/javascript/status.js index 9385271..b100658 100644 --- a/src/javascript/status.js +++ b/src/javascript/status.js @@ -6,5 +6,5 @@ var message = { setStatus.addEventListener("mousedown", function () { message["statusMessage"] = text.value; - makeRequest("PUT", message, "/lol-chat/v1/me"); + LeagueClient.makeRequest("PUT", message, "/lol-chat/v1/me"); }); From 6466bd82f95a2170a74eb2d803f7655802ca4273 Mon Sep 17 00:00:00 2001 From: Paradax-Elite <69823828+Paradax-Elite@users.noreply.github.com> Date: Sun, 23 Aug 2020 22:28:02 -0400 Subject: [PATCH 19/19] Update status.js