search2.Taobao

search2Taobao

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         search2.Taobao
// @name:zh-CN   咸鱼搜索框
// @namespace    Itzcy
// @version      0.3
// @description  search2Taobao
// @description:zh-CN  简陋的咸鱼搜索框
// @author       Itzcy
// @include      https://2.taobao.com/*
// @include      http://2.taobao.com/*
// @include      https://s.2.taobao.com/*
// @include      http://s.2.taobao.com/*
// ==/UserScript==

(function() {
    'use strict';

    window.onload = function(){
        var header = document.getElementById("J_IdleHeader");
        if (header) {
            console.log(header.innerHTML);
            var searchBoxHtml = "<div class=\"idle-search\">" + 
          "<form method=\"get\" action=\"//s.2.taobao.com/list\" name=\"search\" target=\"_top\">" + 
            "<input class=\"input-search\" id=\"J_HeaderSearchQuery\" name=\"q\" type=\"text\" value=\"\" placeholder=\"搜闲鱼\" />" + 
            "<button class=\"btn-search\" type=\"submit\"><i class=\"iconfont\">&#xe602;</i><span class=\"search-img\"></span></button>" + 
          "</form>" + 
        "</div>";
            header.innerHTML += searchBoxHtml;
            var search_filters = document.getElementsByClassName("search-filters")[0];
            search_filters.style.display = "block";
        } else {
            var header = document.getElementsByClassName('tab-wrap')[0]
            console.log(header.innerHTML);
            var searchBoxHtml = "<div class=\"idle-search\">" + 
          "<form method=\"get\" action=\"//s.2.taobao.com/list\" name=\"search\" target=\"_top\">" + 
            "<input class=\"input-search\" id=\"J_HeaderSearchQuery\" name=\"q\" type=\"text\" value=\"\" placeholder=\"搜闲鱼\" />" + 
            "<button class=\"btn-search\" type=\"submit\">搜索<span class=\"search-img\"></span></button>" + 
          "</form>" + 
        "</div>";
            header.innerHTML += searchBoxHtml;
        }
    
};
})();