-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathteams.js
44 lines (31 loc) · 1.17 KB
/
teams.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const playersDiv = document.getElementsByClassName('content-portrait-grid-l')[0];
const playersDivParent = playersDiv.parentNode;
playersDivParent.insertBefore(createUrlLink(), playersDiv);
function createUrlLink() {
const opggUrlLink = document.createElement('a');
const summonerNames = getSummonerNames();
const url = createOpggUrl(summonerNames);
opggUrlLink.setAttribute('href', url);
opggUrlLink.innerHTML = 'OP.GG';
return opggUrlLink;
}
function getSummonerNames() {
const summonerNames = [];
const infoDivs = document.getElementsByClassName('txt-info');
for (let infoDiv of infoDivs) {
const childDiv = infoDiv.firstElementChild;
if (childDiv === null) {
continue;
}
const title = childDiv.getAttribute('title');
if (title?.includes('LoL Summoner Name')) {
summonerNames.push(childDiv.innerText);
}
}
return summonerNames;
}
function createOpggUrl(summonerNames) {
const opggBaseUrl = 'https://www.op.gg/multisearch/euw?summoners=';
const summonerNameString = encodeURIComponent(summonerNames.join(','));
return opggBaseUrl.concat(summonerNameString);
}