淘宝销量排序

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

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

  1. // ==UserScript==
  2. // @name 淘宝销量排序
  3. // @namespace http://hzy.pw
  4. // @description 在淘宝天猫浏览商品时,自动为你首选 [按销量排序]。方便实用!
  5. // @authuer Moshel
  6. // @homepageURL http://hzy.pw/p/1364
  7. // @license Apache License 2.0
  8. // @supportURL http://weibo.com/moshel
  9. // @icon http://hzy.pw/wp-content/uploads/2015/08/i-300x300.jpg
  10.  
  11. // @include *.taobao.com/*
  12. // @include *.tmall.com/*
  13. // @grant none
  14. // @run-at document_start
  15.  
  16. // @date 08/05/2015
  17. // @modified 03/06/2016
  18. // @version 1.3.1
  19. // ==/UserScript==
  20.  
  21.  
  22. ! function() {
  23. "use strict";
  24.  
  25. var href = location.href;
  26.  
  27. /* 不支持这些界面 */
  28. var tmp = ["buy.tmall.com", "buy.taobao.com", "login.taobao.com"];
  29. for (var i = 0; i < tmp.length; i++)
  30. if (href.indexOf(tmp[i]) >= 0)
  31. return;
  32.  
  33. /* 首先去除掉末尾的 # 信息 */
  34. var tmp = href.split("#", 2),
  35. fixed, hash_str;
  36. if (tmp.length == 2) {
  37. href = tmp[0];
  38. hash_str = tmp[1];
  39. fixed = true;
  40. } else
  41. fixed = false;
  42.  
  43. /* 天猫搜索 */
  44. if (location.hostname === "list.tmall.com" && location.search.indexOf("sort=") < 0)
  45. href += "&sort=d";
  46. /* 淘宝搜索 */
  47. else if (location.hostname === "s.taobao.com" && location.search.indexOf("sort=") < 0)
  48. href += "&sort=sale-desc";
  49. /* 天猫淘宝店铺内搜索&分类浏览 */
  50. else if (location.search && location.search.indexOf("orderType=") < 0)
  51. href += "&orderType=hotsell_desc";
  52.  
  53. /* 还原 # 信息 */
  54. if (fixed)
  55. href += "#" + hash_str;
  56. /* 进行跳转 */
  57. if (href !== location.href)
  58. location.href = href;
  59.  
  60. }();