@@ -43,7 +43,7 @@ function title_to_url(title) {
43
43
return "https://www.smogon.com/dex/ss/pokemon/" + pokemon ;
44
44
}
45
45
46
- function add_picon_links ( room_div ) {
46
+ function add_picon_links ( ) {
47
47
const picons = document . querySelectorAll ( ".teamicons > .picon" ) ;
48
48
for ( const picon of picons ) {
49
49
const label = picon . getAttribute ( 'aria-label' )
@@ -74,14 +74,29 @@ function show_end_battle_notif(discoverer, mutation_records, observer) {
74
74
}
75
75
}
76
76
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
+
77
86
function observe_room ( room_div ) {
78
87
const discoverer = new LiveBattleDiscoverer ( room_div ) ;
79
- ( new MutationObserver ( ( ) => add_picon_links ( room_div ) ) )
88
+ ( new MutationObserver ( ( ) => add_picon_links ( ) ) )
80
89
. observe (
81
90
room_div . querySelector ( '.battle' ) ,
82
91
{ childList : true , subtree : true }
83
92
) ;
84
93
94
+ ( new MutationObserver ( ( ) => add_calc_link ( ) ) )
95
+ . observe (
96
+ room_div . querySelector ( '.battle' ) ,
97
+ { childList : true , subtree : true }
98
+ ) ;
99
+
85
100
( new MutationObserver (
86
101
( records , observer ) => show_end_battle_notif ( discoverer , records , observer ) )
87
102
)
0 commit comments