// ==UserScript== // @name SGW Item Modification Fixer // @namespace greasyfork.org // @version 1.1 // @grant none // @require https://greasyfork.org/scripts/10208-gm-api-script/code/GM%20API%20script.js?version=54964 // @include https://sellers.shopgoodwill.com/sellers/modifyItem.asp* // @description Keeps a log of edits // @downloadURL none // ==/UserScript== $('*[name]').not('[id]').each(function(){ $(this).attr('id', $(this).attr('name')); }); if ($('#itemSellerInfo').val().indexOf("[[<") < 0) { var labels = { // 'itemTitle' : 'Title', // 's1' : 'Cat', // 'table' : 'Description', 'itemWeight' : 'ShipWt', // 'itemDisplayWeight' : 'RealWt', 'itemShippingPrice' : 'Shipp$', 'itemShipMethod' : 'ShipBy', // 'itemsellerstore' : 'Store', 'itemSellerInventoryLocationID' : 'Loc', } var values = {}; $.each(labels, function(elementID, fieldLabel){ values[fieldLabel] = $('#'+elementID).val(); }); $('body').append("
"); $('#originalValues').data('originalValues', values); /* var labelsCB = { 'itemNoCombineShipping' : 'No combine shipping', 'itemAutoInsurance' : 'Automatic insurance (USPS)', } var valuesCB = {}; $.each(labelsCB, function(elementID, fieldLabel){ if ($('#'+elementID+":checked").length > 0) { valuesCB[fieldLabel] = 'Yes'; } else { valuesCB[fieldLabel] = 'No'; } }); $('body').append("
"); $('#originalValuesCB').data('originalValuesCB', valuesCB); */ $('#submit1').bind("click", function(e){ e.preventDefault(); var labels = { // 'itemTitle' : 'Title', // 's1' : 'Cat', // 'table' : 'Description', 'itemWeight' : 'ShipWt', // 'itemDisplayWeight' : 'RealWt', 'itemShippingPrice' : 'Ship$', 'itemShipMethod' : 'ShipBy', // 'itemsellerstore' : 'Store', 'itemSellerInventoryLocationID' : 'Loc', } originalValues = $('#originalValues').data('originalValues'); // originalValuesCB = $('#originalValuesCB').data('originalValuesCB'); var changedValues = {}; var newValues = {}; // var changedValuesCB = {}; // var newValuesCB = {}; $.each(labels, function(elementID, fieldLabel) { if ($('#'+elementID).val() != originalValues[fieldLabel]){ changedValues[fieldLabel] = originalValues[fieldLabel]; newValues[fieldLabel] = $('#'+elementID).val(); } }); /* $.each(labelsCB, function(elementID, fieldLabel) { oldVal = originalValuesCB[fieldLabel]; if ($('#'+elementID+":checked").length > 0) { newVal = "Yes"; } else { newVal = "No"; } if (newVal != oldVal){ changedValuesCB[fieldLabel] = oldVal; newValuesCB[fieldLabel] = newVal; } });*/ var d = new Date(); if (!$.isEmptyObject(changedValues) || !$.isEmptyObject(changedValuesCB)) { myID = 'edit-' + d.getTime(); myTable = "[[<" + d.getMonth() + "/" + d.getDate() + ", " + (d.getHours() - 2) + ":" + ("0" + d.getMinutes()).slice(-2) + " PT- "; if (!$.isEmptyObject(changedValues)){ $.each(changedValues, function(fieldLabel, originalValue){ myTable += fieldLabel + ": "; myTable += originalValue; myTable += ";"; }); } /* if (!$.isEmptyObject(changedValuesCB)){ $.each(changedValuesCB, function(fieldLabel, originalValue){ myTable += fieldLabel + ": "; myTable += originalValue; myTable += "
"; }); }*/ myTable += "]]
"; $('body').first().append(myTable); myNote = $('#itemSellerInfo').val(); $('#itemSellerInfo').val(myNote + myTable) } else { console.dir(changedValues); } $('#FORM1').submit(); }); } $('#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()); // TODO: Shipping calculator? $('#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 bot 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(""); $('.fakeButton').css({ 'border' : '1px solid #CCC', 'background-color' : '#EEE', 'padding' : '3px', 'margin' : '3px', }); // don't forget checkboxes! also #table does not have a val()... // can I touch $('body.WebWizRTEtextarea')???