search2.Taobao

search2Taobao

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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;
        }
    
};
})();