KG - upload: add [img] tags

adds link to auto tag image URLs

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        KG - upload: add [img] tags
// @description adds link to auto tag image URLs
// @namespace   KG
// @include     http*://*karagarga.in/upload.php*
// @grant	none
// @version     0.4
// ==/UserScript==

var d = document.getElementsByName("descr")[0];

if (d && d.type != 'hidden') {  // only run on second step of upload.php

	 var code = 'javascript: '
		 + 'var d = document.getElementsByName("descr")[0];'
		 + 'd.value = d.value.replace(/^\\s+(?=http)/gim, "");'		 
		 + 'd.value = d.value.replace(/(https?:\\S*?\\S\\.(png|jpg|jpeg|gif))/gi, "[img]$1[/img]\\n");'
		 + 'return false;'
		 ;
	 
	 var tagImg = document.createElement("a");
	 tagImg.setAttribute("onclick", code);
	 tagImg.textContent = "Add [IMG][/IMG] tags";
	 tagImg.href = "#";
	 
	 d.parentNode.insertBefore(tagImg, d.nextSibling);
}