hwm_clickable_links

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

Versione datata 10/03/2015. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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

})();