在淘宝天猫浏览商品时,自动为你首选 [按销量排序]。方便实用!
当前为
// ==UserScript==
// @name 淘宝销量排序
// @namespace http://hzy.pw
// @description 在淘宝天猫浏览商品时,自动为你首选 [按销量排序]。方便实用!
// @authuer Moshel
// @homepageURL http://hzy.pw/p/1364
// @license Apache License 2.0
// @supportURL http://weibo.com/moshel
// @icon http://hzy.pw/wp-content/uploads/2015/08/i-300x300.jpg
// @include *.taobao.com/*
// @include *.tmall.com/*
// @grant none
// @run-at document_start
// @date 8/5/2015
// @modified 12/4/2015
// @version 1.3
// ==/UserScript==
!function(){
var href = window.location.href;
if ( href.indexOf("buy.taobao.com") < 0 && href.indexOf("login.taobao.com") < 0 ){ /* 不支持这些界面 */
var href0 = href;
/* 首先去除掉末尾的 # 信息 */
var suzu = href.split("#",2);
if ( suzu.length == 2 ) {
href = suzu[0];
var fixed = 1;
}
else
var fixed = 0;
if ( href.indexOf("?")>0 && href.indexOf("orderType=") < 0 ) /* 天猫淘宝店铺内搜索&分类浏览 */
href += "&orderType=hotsell_desc";
if ( href.indexOf("list.tmall.com/")>0 ) { /* 天猫搜索 */
if ( href.indexOf("&sort=") < 0 )
href += "&sort=d";
}
else if( href.indexOf("s.taobao.com/")>0 ) { /* 淘宝搜索 */
if ( href.indexOf("&sort=") < 0 )
href += "&sort=sale-desc";
}
/* 还原 # 信息 */
if ( fixed )
href += "#" + suzu[1];
/* 进行跳转 */
if ( href != href0 )
window.location.href = href;
} /* end if not buying page */
}();