// ==UserScript== // @name SGW Item Modification Helper // @namespace greasyfork.org // @version 1.4.0.9 // @grant none // @include https://sellers.shopgoodwill.com/sellers/modifyItem.asp* // @require https://greasyfork.org/scripts/37273-underdollar-jquery-replacement/code/Underdollar%20jQuery%20replacement.js?upDate=2018_01_11sq2 // @description Improves the modification page // @downloadURL https://update.greasyfork.icu/scripts/23448/SGW%20Item%20Modification%20Helper.user.js // @updateURL https://update.greasyfork.icu/scripts/23448/SGW%20Item%20Modification%20Helper.meta.js // ==/UserScript== console.log('squirrel?') // @require https://greasyfork.org/scripts/23449-gm-api-script/code/GM%20API%20script.js?upDate=2016_09_23 //NodeList.prototype.forEach = Array.prototype.forEach; //Array.prototype.forEach.call(document.querySelectorAll('*[name]'), function(el) { document.querySelectorAll('*[name]').forEach(function(el) { if (typeof el.id == 'undefined' || el.id.length < 1) { el.id = el.getAttribute('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')); // no appendTo, appendTo is stupid _$('#contentTD').append(_$('#itemSellerInventoryLocationID').parent().attr('id', 'itemSellerInventoryLocationIDContainer')); _$('#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").append(_$('#gesMN_shippingCalculatorContainer')); var sgwTimeouts = window.setTimeout(function(){ 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){//__$.each == __$().each if (myCat.indexOf(category) >= 0) { noCombine = true; console.log('badCat: ' + category); } }); if (noCombine == false) { var myDescription = ''; if (typeof _$('#WebWizRTE').contents()[0]['body']['innerText'] != 'undefined') { // this may not work 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(){ var method; var actualWeight = _$('#gesMN_actualWeight').val(); var shippingWeight = 0; var shippingCharge = 0; console.log(actualWeight); if (_$('#gesMN_shippingWeight').filter(function(el){ return _$(el).isVisible(); }).length > 0) { shippingWeight = _$('#gesMN_shippingWeight').html(); _$('#itemShipMethod').val(2); _$('#itemAutoInsurance').attr('checked', false); console.log(shippingWeight); } else if (_$('#gesMN_shippingCharge').filter(function(el){ return _$(el).isVisible(); }).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')???