Straight Techgig

Remove URL redirection from TechGig

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

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

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 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);