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.

当前为 2015-10-11 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

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