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

Changes profile links on gamefaqs.com

当前为 2016-05-07 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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/');
}