// ==UserScript== // @name:zh-CN 淘宝搜索PLUS // @name:zh-TW 淘寶搜索PLUS // @name taobao search plus // @description:zh-CN 淘宝搜索页面自动加载店铺评分,无需鼠标悬停查看!快速查看店铺评分以及同行对比! | 搜索页面自定义排序方式与显示方式 // @description:zh-TW 淘寶搜索頁面自動加載店鋪評分,無需鼠標懸停查看!快速查看店鋪評分以及同行對比! | 搜索頁面自定義排序方式與顯示方式 // @description Auto load shop information, customize the default sort order and ui style(gird or list). // @icon https://www.taobao.com/favicon.ico // @version 1.0.1 // @author olOwOlo // @namespace https://olowolo.com // @homepage https://github.com/olOwOlo/script/tree/master/taobao-search-plus // @supportURL https://github.com/olOwOlo/script // @license MIT // @match https://s.taobao.com/search?* // @run-at document-start // @grant GM_setValue // @grant GM_getValue // @grant GM_addStyle // @grant GM_registerMenuCommand // @downloadURL none // ==/UserScript== // /* * Copyright (c) 2017 olOwOlo * Released under the MIT License. */ (function () { 'use strict' const DEBUG = false function myLog (str) { if (DEBUG) window.console.log(str) } (function () { let globalSort = typeof GM_getValue('sort') === 'undefined' ? 'default' : GM_getValue('sort') let globalStyle = typeof GM_getValue('style') === 'undefined' ? 'grid' : GM_getValue('style') myLog(`[sort = ${GM_getValue('sort')}, style = ${GM_getValue('style')}]`) function parseArgument () { const argvMap = new Map() const argvArray = location.search.substr(1).split('&') for (const string of argvArray) { argvMap.set(...string.split('=')) } return argvMap } const argv = parseArgument() let href = location.href if (globalSort !== 'default' && typeof argv.get('sort') === 'undefined') { href += `&sort=${globalSort}` } if (globalStyle !== 'grid' && typeof argv.get('style') === 'undefined') { href += `&style=${globalStyle}` } if (href !== location.href) { myLog(`redirect... Old href = [${location.href}]`) location.href = href } const sortOption = ['default', 'renqi-desc', 'sale-desc', 'credit-desc', 'price-asc', 'price-desc', 'total-asc', 'total-desc'] const styleOption = ['grid', 'list'] class Setting { // 传入数据{sort: sort, style: style}为有效值 constructor (setting) { this.sort = setting.sort this.style = setting.style } toString () { return `[sort = ${this.sort}, style = ${this.style}]` } createUI () { const userInterface = document.createElement('div') userInterface.innerHTML = '