Skip to content

Commit f611438

Browse files
committed
Add link to calculator
1 parent 203e0d3 commit f611438

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

content.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function title_to_url(title) {
4343
return "https://www.smogon.com/dex/ss/pokemon/" + pokemon;
4444
}
4545

46-
function add_picon_links(room_div) {
46+
function add_picon_links() {
4747
const picons = document.querySelectorAll(".teamicons > .picon");
4848
for (const picon of picons) {
4949
const label = picon.getAttribute('aria-label')
@@ -74,14 +74,29 @@ function show_end_battle_notif(discoverer, mutation_records, observer) {
7474
}
7575
}
7676

77+
function add_calc_link() {
78+
const spriteDiv = document.querySelector(".leftbar > .trainer > .trainersprite");
79+
if (spriteDiv === null) {
80+
return
81+
}
82+
spriteDiv.onclick = () => window.open("https://calc.pokemonshowdown.com/randoms.html?mode=randoms");
83+
spriteDiv.style.cursor = "pointer";
84+
}
85+
7786
function observe_room(room_div) {
7887
const discoverer = new LiveBattleDiscoverer(room_div);
79-
(new MutationObserver(() => add_picon_links(room_div)))
88+
(new MutationObserver(() => add_picon_links()))
8089
.observe(
8190
room_div.querySelector('.battle'),
8291
{childList: true, subtree: true}
8392
);
8493

94+
(new MutationObserver(() => add_calc_link()))
95+
.observe(
96+
room_div.querySelector('.battle'),
97+
{childList: true, subtree: true}
98+
);
99+
85100
(new MutationObserver(
86101
(records, observer) => show_end_battle_notif(discoverer, records, observer))
87102
)

0 commit comments

Comments
 (0)