wgRelevantUserName was added to MW in 1.23, but it doesn't exist when viewing an IP range on (at least) Special:Block and Special:Contributions (compare 192.168.0.2 and 192.168.0.0/16). Some awkward workarounds are possible but inconsistent (using #mw-bi-target or input[name=wpTarget] on Special:Block, input[name=target].mw-input on Special:Contributions); it'd be nice to have a unified and reliable way to get it, regardless of user type.
Of note: it seems to always exist on Special:DeletedContributions, and does so on Special:Log iff the range is given with the user= parameter (e.g., https://en.wikipedia.org/wiki/Special:Log?user=192.168.0.0%2F16).