hwm_clickable_links

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

Stan na 13-03-2015. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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

})();