Greasy Fork is available in English.
Adds simple filters to menus on shopgoodwill
当前为
// ==UserScript==
// @name SGW Menu Filterer
// @namespace greasyfork.org
// @version 1.1.1
// @grant none
// @require http://code.jquery.com/jquery-2.1.3.js
// @include https://sellers.shopgoodwill.com/*
// @exclude https://sellers.shopgoodwill.com/sellers/newAuctionItem-catsel.asp*
// @description Adds simple filters to menus on shopgoodwill
// ==/UserScript==
jQuery.fn.filterByText = function(textbox, selectSingleMatch) {
return this.each(function() {
var select = this;
var options = [];
$(select).find('option').each(function() {
options.push({value: $(this).val(), text: $(this).text()});
});
$(select).data('options', options);
$(textbox).bind('change keyup', function() {
var options = $(select).empty().scrollTop(0).data('options');
var search = $.trim($(this).val());
var regex = new RegExp(search,'gi');
$.each(options, function(i) {
var option = options[i];
if(option.text.match(regex) !== null) {
$(select).append(
$('<option>').text(option.text).val(option.value)
);
}
});
if (selectSingleMatch === true &&
$(select).children().length === 1) {
$(select).children().get(0).selected = true;
}
});
});
};
skipNames = ["sortBy"];
var selectCount = 0;
$('select').each(function(){
myNewBox = selectCount + "Box";
myName = $(this).attr('name');
var skip = 0;
$.each(skipNames, function(i, name){
if (myName.indexOf("sortBy") >= 0) {
skip++;
}
});
myID = this.id;
if ($('#' + myID + ' option').length <= 5) {
skip++;
}
if (skip < 1) {
$(this).before("<div id='" + myNewBox + "C' class='boxContainer'><input id='" + myNewBox + "' type='text' class='filterBox'><span id='" + myNewBox + "T' class='boxText'style='opacity:.75; position: relative; left:-100px; top:-1px; font-size:12px; font-weight: normal;'>(filter)</span></div>");
$(this).filterByText($('#' + myNewBox), true);
}
selectCount++;
});
$('.filterBox').each(function(){
myID = this.id;
$(this).css({
"transform" : "scale(.85,.85)",
"-ms-transform" : "scale(.85,.85)",
"-webkit-transform" : "scale(.85,.85)",
"background-color" : "#F3F3F3",
"position" : "relative",
"left" : "-10px",
});
$(this).append("");
$(this).click(function(){
$('#' + myID + 'T').remove();
});
});
$('.boxText').click(function(){
myID = this.id.slice(0, -1);
$(this).remove();
$('#' + myID).focus();
});
$('.boxContainer, .boxText').css({
"margin" : "0px"
});