// ==UserScript== // @name SGW Item Modification Helper // @namespace greasyfork.org // @version 1.4.0.1 // @grant none // @include https://sellers.shopgoodwill.com/sellers/modifyItem.asp* // @description Improves the modification page // @downloadURL none // ==/UserScript== // @require https://greasyfork.org/scripts/23449-gm-api-script/code/GM%20API%20script.js?upDate=2016_09_23 $ = window.$; $('*[name]').not('[id]').each(function(){ $(this).attr('id', $(this).attr('name')); }); $('#itemTitle').parent().parent().parent().hide(); $('#itemTitle').parent().parent().parent().before(""); $('#contentTD').append("

Item Title:

"); $('#itemTitleContainer').append($('#itemTitle')); $('#contentTD').append("

Category:

"); $('#itemCategoryContainer').append($('#s1')); $('#contentTD').append("

Description:

"); $('#itemDescriptionContainer').append($('#colourPalette').parent()); $('#contentTD').append("
"); $('#itemShippingDetailsContainer').append("

Shipping Weight:

"); $('#itemShippingWeightContainer').append($('#itemWeight')); $('#itemShippingDetailsContainer').append("

Display (Actual) Weight:

"); $('#itemDisplayWeightContainer').append($('#itemDisplayWeight')); $('#itemShippingDetailsContainer').append("

Shipping Charge:

"); $('#itemShippingPriceContainer').append($('#itemShippingPrice')); $('#itemShippingDetailsContainer').append("

Shipping Method:

"); $('#itemShipMethodContainer').append($('#itemShipMethod')); $('#itemShippingDetailsContainer').append("

Item Shipment Combining:

"); $('#itemNoCombineShippingContainer').append($('#itemNoCombineShipping')); $('#itemNoCombineShippingContainer').append(" Select this option if the buyer of this item should not be allowed to combine this item with shipment of other items."); $('#itemShippingDetailsContainer').append("

Auto Include Insurance (USPS Only):

"); $('#itemAutoInsuranceContainer').append($('#itemAutoInsurance')); $('#contentTD').append("

Seller Store:

"); $('#itemsellerstoreContainer').append($('#itemsellerstore')); $('#itemSellerInventoryLocationID').parent().attr('id', 'itemSellerInventoryLocationIDContainer').appendTo($('#contentTD')); $('#contentTD').append("

Seller Private Description:

"); $('#itemSellerInfoContainer').append($('#itemSellerInfo')); $('#contentTD').append("

Show/hide hidden fields/etc.

"); $('#contentTD').parent().after(""); $('#hiddenJunkTD').append("

Item Quantity:

"); $('#itemQuantityContainer').append($('#itemQuantity').parent()); $('#hiddenJunkTD').append("

Minimum Bid:

"); $('#itemMinimumBidContainer').append($('#itemMinimumBid').parent()); $('#hiddenJunkTD').append("

Bid Increment:

"); $('#itemBidIncrementContainer').append($('#itemBidIncrement').parent()); $('#hiddenJunkTD').append("

Reserve Price:

"); $('#itemReserveContainer').append($('#itemReserve').parent()); $('#itemReserve').parent().children().first().remove(); $('#hiddenJunkTD').append("

Buy Now Price:

"); $('#itemBuyNowPriceContainer').append($('#itemBuyNowPrice').parent()); $('#itemBuyNowPrice').parent().children().first().remove(); $('#hiddenJunkTD').append("

"); $('#itemActualDimensionsContainer').append($('#itemLength').parent().parent().parent()); $('#hiddenJunkTD').append("

"); $('#itemShippingDimensionsContainer').append('Shipping Dimension - Length x Width x Height in inches (optional):'); $('#itemShippingDimensionsContainer').append($('#itemShipLength')); $('#itemShippingDimensionsContainer').append(" (Numbers and decimal point '.' only) Used for shipping optimization and prevention of oversized charges."); $('#hiddenJunkTD').append("

Shipping:

"); $('#itemShippingContainer').append($('#itemShipping')); $('#itemShippingContainer').append($('select[name="itemShipping"]')); $('#hiddenJunkTD').append("

Handling Charge:

"); $('#itemHandlingPriceContainer').append($('#itemHandlingPrice').parent()); $('#itemHandlingPrice').parent().children().first().remove(); $('#hiddenJunk').after(""); $('#itemShipMethod option[value="3"]').text('Post Office'); $('#itemTitleContainer').after('
You have characters remaining.
'); $("#myCounter").html(50-$('#itemTitle').val().length); $('#itemTitle').bind('keyup', function(){ $("#myCounter").html(50-$('#itemTitle').val().length); }); // --------- Shipping calculator -------------------------------------------- if ($('#gesMN_shippingCalculatorContainer').length > 0) { $("#itemDescriptionContainer").after($('#gesMN_shippingCalculatorContainer')); var sgwTimeouts = window.setTimeout(function(){ function buttonClickAnimate(button) { var myBGColor = button.css('background-color'); button.animate({'background-color' : darken(button.css('background-color'), 0.1)},250).animate({'background-color' : myBGColor},400); // button.css(); if ($('#gesMN_checkMark').length < 1) { button.after("
"); } else { $('#gesMN_checkMark').html('✔').css('color', '#00e600'); } } function darken(color, modifier) { var parts = color.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); delete(parts[0]); for (var i = 1; i <= 3; ++i) { parts[i] = Math.min(Math.ceil(parts[i]*(1-modifier)), 255); } return 'rgb(' + parts[1] + ',' + parts[2] + ',' + parts[3] + ')'; } function darkenElement(element, modifier) { var bgColor = element.css('background-color'); dark = darken(bgColor, modifier); darker = darken(bgColor, modifier*2); console.log(dark); console.log(darker); element.css({'background-color' : darker, /*'border-color' : borderColor*/}).animate({ 'background-color' : dark, }, 500); } function combineCheck(){ var noCombine = false; var myWeight = $('#itemWeight').val(); if (myWeight >= 20) { console.log('badWeight: >= 20'); noCombine = true; } else if ($('#combineCheck').html() != 'true') { var myCat = $('#s1').val(); var badCats = ['Paintings', 'Prints', 'Strings', 'Brass', 'Formalwear', 'Outerwear', 'Wedding > Dresses', 'Lamps', 'Dinnerware', 'Sewing Machines', 'Typewriters', 'Receivers', 'Turntables', 'Dinnerware', 'Trains']; $.each(badCats, function(index, category){ if (myCat.indexOf(category) >= 0) { noCombine = true; console.log('badCat: ' + category); } }); if (noCombine == false) { var myDescription = ''; if (typeof $('#WebWizRTE').contents()[0]['body']['innerText'] != 'undefined') { var myDesc = $('#WebWizRTE').contents()[0]['body']['innerText'].replace(/(?:\r\n|\r|\n)/g, '').toLowerCase(); } var myTitle = $('#itemTitle').val().toLowerCase(); var badWords = ['Framed', 'Saxophone', 'Guitar', 'Keyboard', 'Trombone', 'Telescope', 'Saxophone', 'Lamp', 'Snowboard', 'Skateboard', 'Glass', 'Crystal', 'Cast iron', 'Tool', 'Drum', 'Sewing machine', 'Typewriter', 'Printer', 'Desktop', 'Receiver', 'Turntable', 'Monitor']; // console.log(myDescription); // console.log(myTitle); $.each(badWords, function(index, word){ word = word.toLowerCase(); if (myDescription.indexOf(word) >= 0 || myTitle.indexOf(word) >= 0) { noCombine = true; console.log('badWord: '+word); } else { } }); if (noCombine == false && (myCat.indexOf('Speaker') >= 0 || myTitle.indexOf('speaker') >= 0 || myDescription.indexOf('speaker') >= 0) && myWeight > 5) { noCombine = true; console.log('badWeight (speaker)'); } } } if (noCombine == true) { console.log('no combine'); $('#itemNoCombineShipping').attr('checked', true); } else { console.log('combine'); $('#itemNoCombineShipping').attr('checked', false); } } function dummyWeight() { if ($('#itemWeight').val().length < 1) { $('#itemWeight').val(1); } if ($('#itemDisplayWeight').val().length < 1) { $('#itemDisplayWeight').val(1); } } function setCombinable(bool) { // true == CAN be combined; false == CANNOT $('#combineCheck').html(bool); if (bool === true || bool == 'true') { $('itemNoCombineShipping').attr('checked', false); } else { $('itemNoCombineShipping').attr('checked', true); } } function getElement(queryString) { if (queryString.indexOf('#') == 0) { return document.getElementById(queryString.replace('#','')); } else { return document.querySelectorAll(queryString)[0]; } } function getElements(queryString) { return document.querySelectorAll(queryString); } function hide(el){ el.style.display = 'none'; el.classList += 'gesHidden'; return false; } function show(el){ el.style.display = ''; return false; } function addCSS(element, styleText) { element.style.cssText +=';'+ styleText; return false; } $('#gesMN_useThisButton').bind('click', function(){ buttonClickAnimate($(this)); var method; var actualWeight = $('#gesMN_actualWeight').val(); var shippingWeight = 0; var shippingCharge = 0; console.log(actualWeight); if ($('#gesMN_shippingWeight:visible').length > 0) { shippingWeight = $('#gesMN_shippingWeight').html(); $('#itemShipMethod').val(2); $('#itemAutoInsurance').attr('checked', false); console.log(shippingWeight); } else if ($('#gesMN_shippingCharge:visible').length > 0) { shippingWeight = actualWeight; $('#itemShipMethod').val(3); $('#itemAutoInsurance').attr('checked', true); shippingCharge = $('#gesMN_shippingCharge').html(); } else { shippingWeight = actualWeight; $('#itemShipMethod').val(0); $('#itemAutoInsurance').attr('checked', false); } $('#itemWeight').val(shippingWeight); $('#itemDisplayWeight').val(actualWeight); $('#itemShippingPrice').val(shippingCharge); }); }, 1100); } $('.fakeButton').css({ 'border' : '1px solid #CCC', 'background-color' : '#EEE', 'padding' : '3px', 'margin' : '3px', }); // can I touch $('body.WebWizRTEtextarea')???