Greasy Fork

Greasy Fork is available in English.

淘宝销量排序

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

当前为 2016-04-03 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==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.0
// ==/UserScript==


! function() {
    "use strict";

    var href = location.href;

    /* 首先去除掉末尾的 # 信息 */
    var tmp = href.split("#", 2), fixed;
    if (tmp.length == 2) {
        href = tmp[0];
        fixed = true;
    } else
        fixed = false;

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

    /* 还原 # 信息 */
    if (fixed)
        href += location.hash;
    
    /* 进行跳转 */
    if (href !== location.href)
        location.href = href;

}();