taobao_pureurl

淘寶網址清理

当前为 2014-07-31 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        taobao_pureurl
// @namespace   tbpu
// @description 淘寶網址清理
// @include     http://detail.tmall.com/*
// @include     https://detail.tmall.com/*
// @include     *.taobao.com/*
// @version     1.3
// ==/UserScript==
String.prototype.repeat = function(n) {
  return Array(n + 1).join(this);
};
String.prototype.downcase = function() {
  return this.toLowerCase();
};
String.prototype.upcase = function() {
  return this.toUpperCase();
};
String.prototype.find = function(str) {
  return this.indexOf(str);
};
String.prototype.has = function(str) {
  return (this.indexOf(str)) >= 0;
};
var sPageUrl = window.location.href;
if( sPageUrl.has('item.taobao.com') || sPageUrl.has('detail.tmall.com')  )
{
	var q = sPageUrl.match(/id=(\d+)/)
	if( q.length > 0 ){
		history.replaceState(null, null, 'item.htm?id='+q[1] );
	}
}else if ( sPageUrl.has('s.taobao.com') ){
	
	var query = '';
	if( sPageUrl.has('q=') )
	{
		var q = sPageUrl.match(/q=[^&(!#)]+/);
		query += '?' + q[0];
	}
	if( sPageUrl.has('cat=') ){
		var q = sPageUrl.match(/cat=[\d+]+/);
		query += '&' + q[0];
	}
	if( sPageUrl.has('sort=') ){
		var q = sPageUrl.match(/sort=[^&]+/);
		query += '&' + q[0];
	}
	if( sPageUrl.has('tab=') ){
		var q = sPageUrl.match(/tab=(all|mall|old)/);
		if(q[0] !=='tab=all')
		{
			query += '&' + q[0];
		}
	}
	if( sPageUrl.has('s=') )
	{
		var q = sPageUrl.match(/s=(\d+)+/);
		query += '&' + q[0];
	}
	if( query != '' ){
		history.replaceState(null, null, 'search'+query);
	}
}