Greasy Fork is available in English.
Keeps a log of edits
当前为
// ==UserScript==
// @name SGW Item Modification Helper
// @namespace greasyfork.org
// @version 1
// @grant none
// @require http://greasyfork.icu/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
// ==/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("<div id='originalValues'></div>");
$('#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("<div id='originalValuesCB'></div>");
$('#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 += "<br>";
});
}*/
myTable += "]]<br>";
$('body').first().append(myTable);
myNote = $('#itemSellerInfo').val();
$('#itemSellerInfo').val(myNote + myTable)
} else {
console.dir(changedValues);
}
$('#FORM1').submit();
});
}
// don't forget checkboxes! also #table does not have a val()...
// can I touch $('body.WebWizRTEtextarea')???