Skip to content

Commit

Permalink
Release beta
Browse files Browse the repository at this point in the history
  • Loading branch information
snowflake-x committed Jul 19, 2023
0 parents commit daea901
Show file tree
Hide file tree
Showing 7 changed files with 742 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# TeamInsightX
Search for teammate information



This is a [Pengu Loader](https://pengu.lol) Plugin

Thank for [nomi](https://github.com/nomi-san) continuous help and support

# Implement

Borrowed the idea from [balance-buff-viewer](https://github.com/nomi-san/balance-buff-viewer)

# 📝 TODO
- [ ] Multi-language support
- [ ] Add settings options

# Existing features
Homepage privacy status check

Historical record inquiry

Rank information inquiry

KDA display
107 changes: 107 additions & 0 deletions css/resource.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
.head-main {
position: relative;
background-color: rgb(0, 0, 0);
display: flex;
}

.icon-head {
height: 32px;
width: 32px;
background-size: cover;
}

.user-history-result {
width: 60px;
text-align: center;
position: relative;
padding-top: 6px;
}

.user-history-result-text {
display: block;
font-size: 14px;
font-weight: 700;
letter-spacing: 0.075em;
text-align: center;
}

.user-history-result-text.victory {
color: #0acbe6
}

.user-history-result-text.defeat {
color: #ff2345
}

.user-history-result-mode {
color: #a09b8c;
display: block;
font-size: 0.7em
}


.user-history-items {
display: flex;

}

.user-history-items div {
height: 32px;
width: 32px;
background: rgba(1, 10, 19, .5);
border: thin solid #463714;
margin: 0 -1px -4px 0;
background-size: cover;
}

/* 战绩详情区块 */
.match-data {
position: relative;
top: 2.5px;
color: #a09b8c;
font-weight: 700;
letter-spacing: .05em;
direction: ltr;
font-size: 13px;
display: block
}

/* 补刀 */
.user-minions {
display: inline-block;
position: relative;
min-width: 45px;
}


/* 玩家补刀标志 */
.user-minions:after {
background-size: 100%;
content: "";
display: inline-block;
height: 12px;
margin-left: 0px;
opacity: .6;
position: relative;
top: 3px;
transition: opacity .3s ease;
width: 11px
}

/* 金币 */
.user-gold {
display: inline-block;
position: relative;
}

/* 玩家金钱 */
.user-gold:after {
background-size: 100%;
content: "";
display: inline-block;
height: 10px;
margin-left: 2px;
opacity: .6;
transition: opacity .3s ease;
width: 11px
}
207 changes: 207 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
import { Tooltip } from "./js/tooltip";
import { LoadDataInfo } from "./js/LoadDataInfo";
import { DataQuery } from "./js/DataQuery";
import "./css/resource.css";
const delay = (t) => new Promise((r) => setTimeout(r, t));
let playerManager = document.getElementById("lol-uikit-layer-manager-wrapper");

let tooltip_ = null;
const LoadDataInfo_ = new LoadDataInfo();
const DataQuery_ = new DataQuery();

const tooltips = [];

const version = "beta1";

async function updateInfo() {
const fetchResult = await fetch("/lol-champ-select/v1/session");
const session = await fetchResult.json();
const team = session.myTeam;
const summonerIds = [];
const puuids = [];
const names = [];
const levels = [];
const status = [];
const playerRanks = [];
const leaguePoints = [];
const playerRanks_Mode = [];
const divisionS = [];
for (const item of team) {
if (item.summonerId == 0) {
continue;
}
const [name, statusText, level, puuid] = await DataQuery_.queryPlayerInfo(
item.summonerId
);
console.log(name + "-玩家uuid->" + puuid);
const [LP, Rank, Type, division] = await DataQuery_.queryRank(puuid);
summonerIds.push(item.summonerId);
puuids.push(puuid);
names.push(name);
levels.push(level);
status.push(statusText);
playerRanks.push(Rank);
leaguePoints.push(LP);
playerRanks_Mode.push(Type);
divisionS.push(division);
}
return [
summonerIds,
puuids,
names,
levels,
status,
playerRanks,
leaguePoints,
playerRanks_Mode,
divisionS,
];
}

function unmount() {
tooltips.forEach((tool) => {
tool.umount();
});
tooltips.length = 0;
}

async function add(puuid, begIndex, endIndex, tool) {
const matchData = await DataQuery_.queryMatch(puuid, begIndex, endIndex);
let k = 0,
d = 0,
a = 0;
for (let i = 0; i <= endIndex; i++) {
const heroIcon = LoadDataInfo_.getChampionPath(matchData.championId[i]);
const spell1Id = LoadDataInfo_.getSpellPath(matchData.spell1Id[i]);
const spell2Id = LoadDataInfo_.getSpellPath(matchData.spell2Id[i]);
const wins = matchData.winList[i];
const kills = matchData.killList[i];
const deaths = matchData.deathsList[i];
const assist = matchData.assistsList[i];
const items_id = matchData.items[i];
const items_path = [];
const minions = matchData.Minions[i];
const glod = matchData.gold[i];
const mode = matchData.gameMode[i];
items_id.forEach((data) => {
items_path.push(LoadDataInfo_.getItemIconPath(data));
});

let str = "";
await DataQuery_.queryGameMode(mode)
.then((result) => {
str = result;
})
.catch((error) => {
console.error(error);
});
tool.appendMatchRecord(
heroIcon,
spell1Id,
spell2Id,
wins,
str,
kills,
deaths,
assist,
items_path,
minions,
glod
);
(k = k + kills), (d = d + deaths), (a = a + assist);
}
return (k + a) / d;
}

async function mount() {
const [summonerId, puuid, name, level, status, Rank, LP, Mode, divisionS] =
await updateInfo();
let party;
do {
await delay(100);
party = document.querySelector(".summoner-array.your-party");
} while (!party);
const summoners = party.querySelectorAll(".summoner-container-wrapper");
for (const [index, el] of summoners.entries()) {
if (puuid[index]) {
const tooltip = new Tooltip(playerManager);
tooltips.push(tooltip);

tooltip.mount(
el,
"right",
name[index] + "\tlevel:" + level[index] + "\t生涯:" + status[index],
Mode[index][0] +
":" +
Rank[index][0] +
divisionS[index][0] +
"\t" +
"LP:" +
LP[index][0] +
"\n" +
Mode[index][1] +
":" +
Rank[index][1] +
divisionS[index][1] +
"\t" +
"LP:" +
LP[index][1] +
"\nversion:" +
version
);
const kda = await add(puuid[index], 0, 4, tooltip);
tooltip.setKdaColor(el, kda);
tooltip.repositionElement(el, "right");
el.addEventListener("mouseout", () => tooltip.hide());
el.addEventListener("mouseover", () => {
tooltip.show();
});
}
}
}

function setPlay(el) {
const span = el.querySelector("span");
el.addEventListener("mouseout", () => {
span.textContent = "PLAY";
});
el.addEventListener("mouseover", () => {
span.textContent = "Insight";
});
}

async function load() {
do {
await delay(100);
playerManager = document.getElementById("lol-uikit-layer-manager-wrapper");
} while (!playerManager);
let paly = document.querySelector(".play-button-content");
setPlay(paly);

LoadDataInfo_.initUi();
console.log("TeamInsightX加载成功");
console.log("LCU地址\t->\t" + window.location.href);
console.log("更新数据\t->\t" + (await LoadDataInfo_.update()));
const link = document.querySelector('link[rel="riot:plugins:websocket"]');
const ws = new WebSocket(link.href, "wamp");

const EP_GAMEFLOW = "OnJsonApiEvent/lol-gameflow/v1/gameflow-phase".replace(
/\//g,
"_"
);

ws.onopen = () => {
ws.send(JSON.stringify([5, EP_GAMEFLOW]));
};

ws.onmessage = (e) => {
const [, endpoint, { data }] = JSON.parse(e.data);
if (data === "ChampSelect") {
mount();
} else if (data === "None") {
unmount();
}
};
}

window.addEventListener("load", load);
Loading

0 comments on commit daea901

Please sign in to comment.