Straight Techgig

Remove URL redirection from TechGig

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

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

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 Straight Techgig
// @id	straight_techgig_xifos
// @namespace	  in.co.tossing.toolkit.techgig
// @description	Remove URL redirection from TechGig
// @license	GPL v3 or later version
// @include		*://www.techgig.com/*
// @version	0.1
// @author	XiFoS
// ==/UserScript==

(function (d) {
	var all_a = d.getElementsByTagName('a');
	var a = null;
	var match;
	for(i = 0; i < all_a.length; i++) {
		a = all_a.item(i);
		if(a.href) {
			match = a.href.match(/readnews\.php/);
			if(match) {
				a.href = getQueryVariable(a.href, 'tgnews_link');
			}
		}
	}

	function urldecode(url) {
		return decodeURIComponent(url.replace(/\+/g, ' '));
	}

	function getQueryVariable(url, variable) {
		// remove all until the first `?`
		var query = url.split('?');
		query.shift(1);
		var vars = query.join('?').split('&');
		for (var i = 0; i < vars.length; i++) {
			var pair = vars[i].split('=');
			if (urldecode(pair[0]) == variable) {
				return urldecode(pair[1]);
			}
		}
		return null;
	}
})(document);