有什么好说的
目前為
// ==UserScript==
// @name 淘宝链接自动精简
// @version 0.1
// @author Janeway_ryu
// @description 有什么好说的
// @include *.taobao.com/*
// @include *.tmall.com/*
// @grant none
// @namespace https://greasyfork.org/users/174880
// ==/UserScript==
(function() {
if(window.location.pathname == "/item.htm"){
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return r[2];
return null;
}
var site = window.location.href.match(/^http(s)?:\/\/[^?]*/);
var wd = getQueryString("wd");
var id = getQueryString("id");
var q = getQueryString("q");
var pureUrl;
if (wd != null) {
pureUrl = site[0] + "?wd=" + wd;
} else if (id != null) {
pureUrl = site[0] + "?id=" + id;
} else if (q != null) {
pureUrl = site[0] + "?q=" + q;
} else if (site[0].substr(site[0].length - 13) == "view_shop.htm") {
pureUrl = window.location.protocol + "//" + window.location.host;
} else {
pureUrl = site[0];
}
if(pureUrl != window.location.href){
window.history.pushState({},0,pureUrl);
//window.location.href = pureUrl;
}
}
})();