// ==UserScript== // @name QuickSearch // @namespace http://tampermonkey.net/ // @version 0.2 // @description 快速搜索关键词,半批量! // @author AOQ // @match https://*.findic.com/* // @match http://*.findic.com/* // @match https://*.szlcsc.com/* // @match http://*.szlcsc.com/* // @match https://*.ickey.cn/* // @match http://*.ickey.cn/* // @match https://*.ichunt.com/* // @match http://*.ichunt.com/* // @match https://*.hqchip.com/* // @match http://*.hqchip.com/* // @match https://*.hqbuy.com/* // @match http://*.hqbuy.com/* // @match https://*.hqew.com/* // @match http://*.hqew.com/* // @match https://*.icbase.com/* // @match http://*.icbase.com/* // @match https://*.rightic.cn/* // @match http://*.rightic.cn/* // @match https://*.ichub.com/* // @match http://*.ichub.com/* // @match https://*.findchips.com/* // @match http://*.findchips.com/* // @match https://*.infinigo.com/* // @match http://*.infinigo.com/* // @match https://*.allchips.com/* // @match http://*.allchips.com/* // @match https://*.elecfans.com/* // @match http://*.elecfans.com/* // @match https://*.mouser.cn/* // @match http://*.mouser.cn/* // @match https://*.arrow.cn/* // @match http://*.arrow.cn/* // @match https://*.ti.com/* // @match http://*.ti.com/* // @match https://*.iceasy.com/* // @match http://*.iceasy.com/* // @match https://*.ttic.cc/* // @match http://*.ttic.cc/* // @match https://*.114ic.cn/* // @match http://*.114ic.cn/* // @match https://*.icdeal.com/* // @match http://*.icdeal.com/* // @match https://*.b2b.baidu.com/* // @match http://*.b2b.baidu.com/* // @match https://*b1b.com/* // @match http://*b1b.com/* // @icon https://static.ickimg.com/assets/release3.001/img/icon/favicon_front.ico // @grant GM_addStyle // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @license MPL License // @downloadURL https://update.greasyfork.icu/scripts/465895/QuickSearch.user.js // @updateURL https://update.greasyfork.icu/scripts/465895/QuickSearch.meta.js // ==/UserScript== (function () { if (typeof ($) == 'undefined' && document.head) { var jqueryScript = document.createElement('script'); jqueryScript.src = 'https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.min.js'; document.head.appendChild(jqueryScript); } addStyle(); unsafeWindow.qs_icSites = ["findic.com", "szlcsc.com", "ickey.cn", "ichunt.com", "hqchip.com", "hqbuy.com", "hqew.com", "icbase.com", "rightic.cn", "ichub.com", "findchips.com", "infinigo.com", "allchips.com", "elecfans.com", "mouser.cn", "arrow.cn", "ti.com", "iceasy.com", "ttic.cc", "114ic.cn", "icdeal.com", "b2b.baidu.com", "b1b.com" ]; unsafeWindow.qs_icSearchUrls = ["https://www.findic.com/search?page=1&key=", "https://so.szlcsc.com/global.html?k=", "https://search.ickey.cn/?keyword=", "https://www.ichunt.com/s/?k=", "https://www.hqchip.com/search/{0}.html", "https://www.hqbuy.com/search/", "https://s.hqew.com/{0}.html", "http://www.icbase.com/ProResult.aspx?w=", "http://rightic.cn/search#/part=", "https://www.ichub.com/portal/qa_line?keyword=", "https://www.findchips.com/search/", "https://www.infinigo.com/s?wd={0}&search_type=all", "https://www.allchips.com/search?key={0}&type=1&sp=1", "https://s.elecfans.com/s?type=0&keyword=", "https://www.mouser.cn/c/?q=", "https://www.arrow.cn/arrow_product/product/search?keyword=", "https://www.ti.com/sitesearch/en-us/docs/universalsearch.tsp?langPref=en-US&searchTerm=#q={0}&numberOfResults=25", "https://www.iceasy.com/supply/search-list?keyword=", "https://www.ttic.cc/icpdf/{0}.html", "https://www.114ic.cn/{1}/{0}.html", "https://www.icdeal.com/s/{0}/", "https://b2b.baidu.com/s?q=", "https://www.b1b.com/Search/{0}/" ]; unsafeWindow._thehost = location.host.toLowerCase(); unsafeWindow.icQSWeb = { init: function () { let _icQSHtml = `↑收↑
`; $("body").append(_icQSHtml); $("#i_model").keyup(function (e) { GM_setValue("_icQSKey", $(this).val().trim()); icQSWeb.ShowModelInfo(); }); let defaultIsShow = GM_getValue("_icQSIsShow", true); if (!defaultIsShow) { $("#icQS").hide(); $(".qs_ic_sqhl").text("↓搜↓"); } $(".qs_ic_sqhl").click(function () { if ($("#icQS").css("display") == "none") { $("#icQS").show(); $(".qs_ic_sqhl").text("↑收↑"); GM_setValue("_icQSIsShow", true); } else { $("#icQS").hide(); $(".qs_ic_sqhl").text("↓搜↓"); GM_setValue("_icQSIsShow", false); } }); let defaultTxt = GM_getValue("_icQSKey", ""); if (defaultTxt) { $("#i_model").val(defaultTxt); icQSWeb.ShowModelInfo(true); //删除缓存 //GM_deleteValue("hello") } let defaultNowTxt = GM_getValue("_icNowSKey", ""); if (defaultNowTxt) { $(".qs_ic_cy a").each(function () { var _tempUrl = $(this).attr("href"); if (_tempUrl.indexOf("{0}") > 0) { _tempUrl = _tempUrl.replace(/\{0\}/g, encodeURIComponent(defaultNowTxt)); $(this).attr("href", _tempUrl); } }); } }, ShowModelInfo: function (_toscroll) { var vTxt = $("#i_model").val(); var vArray = vTxt.split("\n"); var vHtml = ""; if (vArray.length == 1) { vArray = vTxt.split(" "); } var _nowKeyIndex = 0; $.each(vArray, function (i) { if (this) { var _tourl = qs_nowUrl; if (_tourl.indexOf("{0}") > 0) { _tourl = _tourl.replace(/\{0\}/g, encodeURIComponent(this)); } else { _tourl = _tourl + encodeURIComponent(this); } if (_tourl.indexOf("{1}") > 0) { _tourl = _tourl.replace(/\{1\}/g, this.substr(0, 1)); } var _theStyle = GM_getValue("_icNowSKey", "") == this ? " color:#069b7e; font-weight: bold;" : ""; if (GM_getValue("_icNowSKey", "") == this) { _nowKeyIndex = i; } vHtml += ''; } }); $("#j_models").html(vHtml); if (_toscroll && _nowKeyIndex > 0 && $("#j_models p").eq(_nowKeyIndex)) { $("#j_models p").eq(_nowKeyIndex)[0].scrollIntoView(true); } }, toICSearch: function (_ptourl, _pnowkey) { GM_setValue("_icNowSKey", decodeURIComponent(_pnowkey)); location.href = _ptourl; } } setTimeout(function () { if (typeof ($) == 'undefined' && jQuery) { $ = jQuery; } var _isIc = false; $.each(qs_icSites, function (i) { if (_thehost.indexOf(this) >= 0) { unsafeWindow.qs_nowUrl = qs_icSearchUrls[i]; unsafeWindow.qs_nowHost = this; _isIc = true; return false; } }); if (_isIc) { icQSWeb.init(); } }, 1000); })(); // 添加 css 样式 function addStyle() { let css = ` .wrap{ padding: 5px } .h1{ font-size: 16px; color: green; } .des{ font-size: 10px; } #icQS h3,#icQS h4{ padding:0px;margin:0px; } #j_models p{ padding:2px;margin:1px; } .qs_ic_sqhl{ position: fixed; right: 2px; top: 0px; width: 30px; height: 25px; line-height: 24px; z-index: 999999999; text-align: center; background-color: #30403c; color: #fff; cursor: pointer; } #j_models a:hover{ text-decoration: underline !important; } .qs_ic_cy{ position: absolute;bottom: 1px;background-color: #ccc;color: green; } .qs_ic_cy h3{ } .qs_ic_cy a{ display: inline-block;min-width: 50px;padding: 3px;text-align: center; } `; GM_addStyle(css) }