hwm_clickable_links

Кликабельные ссылки на форуме и в личной информации персонажей

As of 10.03.2015. See апошняя версія.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name           hwm_clickable_links
// @namespace      Demin
// @description    Кликабельные ссылки на форуме и в личной информации персонажей
// @homepage       https://greasyfork.org/users/1602-demin
// @icon           http://i.imgur.com/LZJFLgt.png
// @version        1.1
// @encoding 	   utf-8
// @include        http://*heroeswm.ru/pl_info.php*
// @include        http://178.248.235.15/pl_info.php*
// @include        http://*lordswm.com/pl_info.php*
// @include        http://*heroeswm.ru/forum_messages.php*
// @include        http://178.248.235.15/forum_messages.php*
// @include        http://*lordswm.com/forum_messages.php*
// ==/UserScript==

(function() {

var version = '1.1';

var url_cur = location.href;

pl_info();
forum();

function pl_info() {
	if (url_cur.indexOf("pl_info.php") == -1) {return;}
	var td_arr = document.getElementsByTagName('td');
	td_arr[td_arr.length - 2].innerHTML = replaceAll(td_arr[td_arr.length - 2].innerHTML.split('<br>'));
}

function forum() {
	if (url_cur.indexOf("forum_messages.php") == -1) {return;}
	var td_arr = document.getElementsByTagName('td');
	for (var i = 0; i < td_arr.length; i++) {
		var td = td_arr[i];
		var attr = td.getAttribute('style');
		if (attr == "color: #000000; padding: 5px; font-size: 13px;") {
			td_arr[i].innerHTML = replaceAll(td_arr[i].innerHTML.split('<br>'));
		}
	}
}

function replaceAll(lines) {
	for (var i = 0; i < lines.length; i++) {
		var words = lines[i].split(' ');
		for (var j = 0; j < words.length; j++) {
			words[j] = replace(words[j]);
		}
		lines[i] = words.join(' ');
	}
	return lines.join('<br>');
}

function replace(a) {
	var b = (a.indexOf("color=") == 0);
	var i = a.indexOf("http://");
	if (i > 1 && !b) {return a;}
	if (i != -1) {
		return a.substring(0, i) + "<a href=\"" + a.substring(i) + "\">" + a.substring(i) + "</a>";
	}
	i = a.indexOf("https://");
	if (i > 1) {return a;}
	if (i != -1 && !b) {
		return a.substring(0, i) + "<a href=\"" + a.substring(i) + "\">" + a.substring(i) + "</a>";
	}	
	i = a.indexOf("ftp://");
	if (i > 1) {return a;}
	if (i != -1 && !b) {
		return a.substring(0, i) + "<a href=\"" + a.substring(i) + "\">" + a.substring(i) + "</a>";
	}		
	return a;
}

})();