Overwatch forums user info

Linkify user names so it directs to playoverwatch profile

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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>';
  });