淘宝销量排序

在淘宝天猫浏览商品时,自动为你首选 [按销量排序]。方便实用!

As of 2016-04-03. See the latest version.

// ==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      /^https?://s.taobao.com/search\?.+/
// @include      /^https?://list.tmall.com/search_product.htm\?.+/
// @grant        none
// @run-at       document_start

// @date         08/05/2015
// @modified     04/03/2016
// @version      1.4.1
// ==/UserScript==


! function() {
    "use strict";

    var href = location.search;

    /* 天猫搜索 */
    if (location.hostname === "list.tmall.com" && href.indexOf("sort=") < 0)
        href += "&sort=d";
    /* 淘宝搜索 */
    else if (location.hostname === "s.taobao.com" && href.indexOf("sort=") < 0)
        href += "&sort=sale-desc";
    /* 天猫淘宝店铺内搜索&分类浏览 
    else if (location.search && href.indexOf("orderType=") < 0)
        href += "&orderType=hotsell_desc"; */
    else
        return;
    
    /* 进行跳转 */
    if (href !== location.search)
        location.search = href;

}();