Overwatch forums user info

Linkify user names so it directs to playoverwatch profile

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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>';
  });