Overwatch forums user info

Linkify user names so it directs to playoverwatch profile

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        Overwatch forums user info
// @namespace   abyx
// @description:en Linkify user names so it directs to playoverwatch profile
// @include     http://*.battle.net/forums/*/overwatch/topic/*
// @version     0.2
// @grant       none
// @description Linkify user names so it directs to playoverwatch profile
// ==/UserScript==

var postsCollection = document.getElementsByClassName("TopicPost-content");
var posts = Array.from(postsCollection);
posts.forEach(function(x) {
  var linkToPosts = x.getElementsByClassName("Author-posts")[1].href;
  var bnet = /a=(.+)$/i.exec(linkToPosts)[1];
  var bnetFormatted = bnet.replace("%23","-");
  var region = /http:\/\/(\w+)\.battle/.exec(document.URL)[1];
  var authorNameElement = x.getElementsByClassName("Author-name")[0];
  var authorName = authorNameElement.innerHTML;
  authorNameElement.innerHTML = '<a href="https://playoverwatch.com/en-us/career/pc/' + region + '/' + bnetFormatted + '">' + authorName + '</a>';
  });