URL Stipper

Takes offsite links that stick the original URL into an onsite link with extra parameters and changes the href to that original URL.

Verze ze dne 11. 10. 2015. Zobrazit nejnovější verzi.

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          URL Stipper
// @namespace     DoomTay
// @description   Takes offsite links that stick the original URL into an onsite link with extra parameters and changes the href to that original URL.
// @version       1.0

// ==/UserScript==

var links = document.links;

var isInArchive = window.location.hostname == "web.archive.org";

//Right now it will only get the "url" tag of a retrieved url, but in the future, other possibilities may open up
for(var l = 0; l < links.length; l++)
{
	if(URLToObject(links[l].href) == null) continue;
	var archivePrefix = isInArchive ? /http:\/\/web\.archive\.org\/web\/\d{1,14}\//.exec(window.location.href) : "";
	if(URLToObject(links[l].href).hasOwnProperty("url")) links[l].href = archivePrefix + URLToObject(links[l].href)["url"];
}

function URLToObject(url)
{
	var URLBits = new Object();

	var splitURL = url.split("?");

	if(splitURL[1] == undefined) return null;
	var params = splitURL[1].split("&");

	for(var i = 0; i < params.length; i++)
	{
		params[i] = params[i].split("=");
		URLBits[params[i][0]] = params[i][1];
	}

	return URLBits;
}