GameFAQs - Change /community/ links to /community/boards/

Changes profile links on gamefaqs.com

目前為 2016-05-07 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        GameFAQs - Change /community/ links to /community/boards/
// @namespace   https://greasyfork.org/en/scripts/19469-gamefaqs-change-community-links-to-community-boards
// @include     http://www.gamefaqs.com/boards/*
// @include     http://www.gamefaqs.com/user/*
// @include     http://www.gamefaqs.com/pm*
// @description:en Changes profile links on gamefaqs.com
// @version     1.03
// @grant       none
// @description Changes profile links on gamefaqs.com
// ==/UserScript==
//user
if (window.location.href.indexOf('/user/') != - 1)
{
  var board = document.getElementsByClassName('board') [0];
  var tr = board.getElementsByTagName('tr');
  if (tr.length != 0)
  {
    for (i = 1; 1 != tr.length; i++) //skip first tr
    {
      modify_href(tr[i]);
    }
  }
} //topic_list and msg_list

if (window.location.href.indexOf('/admin') == - 1 && window.location.href.indexOf('/user/') == - 1 && window.location.href.indexOf('/pm') == - 1)
{
  //topic_list
  var tauthor = document.getElementsByClassName('tauthor');
  if (tauthor.length != 0)
  {
    for (i = 1; i != tauthor.length; i++) //skip first tauthor
    {
      modify_href(tauthor[i]);
    }
  } //msg_list

  var post_author = document.getElementsByClassName('post_author');
  if (post_author.length != 0)
  {
    for (i = 0; i != post_author.length; i++)
    {
      var a_element = post_author[i].getElementsByClassName('name') [0];
      var href = a_element.getAttribute('href');
        a_element.setAttribute('href', href + '/boards/');
    }
  }
} //pb_admin and pm page

if (window.location.href.indexOf('/admin') != - 1 || window.location.href.indexOf('/pm') != - 1)
{
  if (window.location.href.indexOf('?message=') != - 1)
  { //in_message
    modify_href(document.getElementsByClassName('foot') [0]);
  } else { //on pm_list
    var board = document.getElementsByClassName('board') [0];
    var tbody = board.getElementsByTagName('tbody');
    if (window.location.href.indexOf('/pm') != - 1)
    {
      start = 0;
    } else {
      start = 1;
    }
    if (tbody.length != 0)
    {
      for (i = start; i != tbody.length; i++)
      {
        var tr = tbody[i].getElementsByTagName('tr');
        if (tr.length != 0)
        {
          for (j = start; j != tr.length; j++) //skip first tr
          {
            modify_href(tr[j]);
          }
        }
      }
    }
  }
}
function modify_href(parent_element)
{
  var a_element = parent_element.getElementsByTagName('a') [0];
  var href = a_element.getAttribute('href');
    a_element.setAttribute('href', href + '/boards/');
}