// ==UserScript==
// @name SGW Fixer*
// @namespace https://greasyfork.org
// @include https://sellers.shopgoodwill.com/sellers/newAuctionItem-catsel.asp*
// @include https://sellers.shopgoodwill.com/sellers/reviewItem-label.asp*
// @include https://sellers.shopgoodwill.com/sellers/reviewItem-label.asp?state=2
// @include https://sellers.shopgoodwill.com/sellers/fileUpload/renform-jquery-catsel.asp
// @version 7.2.1.8
// @description Implements numerous improvements to the functionality of the Shopgoodwill seller site.
// @grant none
// @require https://greasyfork.org/scripts/23449-gm-api-script/code/GM%20API%20script.js?upDate=2016_09_23
// @require https://greasyfork.org/scripts/23451-sgw-shelves-cats/code/SGW%20Shelves%20%20Cats.user.js?upDate=2017_08_23
// @require https://greasyfork.org/scripts/23450-sgw-fixer-users/code/SGW%20Fixer%20-%20Users.js?upDate=2017_12_28
// @downloadURL none
// ==/UserScript==
var cyberMondayDate = 27; // Cyber Monday 2017 is November 27th, hence 27;
var cyberMondayAuctionDuration = 7; // If any CM items are posted as auctions, how long should they run?
$('*[name]').not('[id]').each(function(){
$(this).attr('id', $(this).attr('name'));
});
window.addEventListener ("message", receiveMessage, false);
var url = document.URL;
var premium = false;
var baseDuration = 0;
//$('a:contains("Seller\'s Guide")').replaceWith("Seller\'s Guide");
function receiveMessage (event) {
var messageJSON;
try {
messageJSON = JSON.parse (event.data);
}
catch (zError) {
// Do nothing
}
var safeValue = JSON.stringify(messageJSON);
if (typeof(messageJSON['lastLocation'])!== "undefined") {
GM_setValue("lastLocation", safeValue);
} else {
GM_setValue("storedPresets", safeValue);
}
}
if (url == "https://sellers.shopgoodwill.com/sellers/reviewItem-label.asp?state=2") {
var myLastLoc = JSON.parse(GM_getValue("lastLocation", ""));
if (typeof myLastLoc !== "undefined") {
$('a:contains("Add")').before("Location: " + myLastLoc['lastLocation'] + "
");
$('a:contains("Add")').attr('href', "https://sellers.shopgoodwill.com/sellers/fileUpload/renform-jquery-catsel.asp");
$('p').first().before("
" + myLastLoc['lastTitle'] + "
");
GM_deleteValue("lastLocation");
}
} else if (url == "https://sellers.shopgoodwill.com/sellers/fileUpload/renform-jquery-catsel.asp") {
window.setInterval(function(){
if (($('.template-download:visible').length > 0) && ($('.template-upload:visible').length <= 0)) {
$('#btnSubmit').trigger('click');
}
}, 20000);
}
if (GM_getValue("lastLocation")) {
myLastLoc = JSON.parse(GM_getValue("lastLocation", ""));
}
// The name as listed is what the script looks for at the top of the page, as in "Welcome Firstname Lastname".
// (Any piece of that is fine: "John L", "John Linnell", and "hn Lin" would all pick out John Linnell)
var thisPoster = "";
var myPosterName = "";
var posterDelay = 0;
$.each(posters, function(name, info) { //working 10/27
re = new RegExp(name,"gi");
if(re.exec($(".smtext").html())) {
thisPoster = name.replace(/ /gi,"");
myPosterName = name;
console.log(thisPoster);
}
});
var presetTypes = {
"Title" : "",
"Store" : "",
"Shipping Weight" : "",
"Display Weight" : "",
"Location" : "",
"Duration" : "",
"Starting Bid" : "",
"BIN Price" : "",
"Ship Charge" : "",
"Ship Type" : "",
// ^^^ general, guitar, art, lot, long, Media <---- note the capital M!
"Ship in own box/between cardboard" : "",
// ^^^ yes for yes, any other value defaults to no
"Dimension 1" : "",
"Dimension 2" : "",
"Dimension 3" : "",
"Skip" : "",
"Owner" : "",
}
var cyberMondayPosters = ["Holden"/*collectibles & jewelry*/, "Jackie", "Alicia", "Jacob"];
var welcomeText = $('table:contains("Welcome")').text();
var cyberMondayPoster = false;
$.each(cyberMondayPosters, function(cmIndex, cmPoster) {
if (welcomeText.indexOf(cmPoster) >= 0) {
presetTypes['Cyber Monday'] = "";
cyberMondayPoster = true;
}
});
if (GM_getValue("storedPresets")) {
var presets = JSON.parse (GM_getValue("storedPresets"));
if (!presets.hasOwnProperty('Owner') || presets['Owner'] != thisPoster) {
presets = {
"Store" : "",
"Shipping Weight" : "",
"Display Weight" : "",
"Location" : "",
"Duration" : "",
"Ship Charge" : "",
"Ship Type" : "",
// ^^^ general, guitar, art, lot, long, Media <---- note the capital M!
"Ship in own box/between cardboard" : "",
// ^^^ yes for yes, any other value defaults to no
"Dimension 1" : "",
"Dimension 2" : "",
"Dimension 3" : "",
"Skip" : "",
"Owner" : thisPoster,
"Cyber Monday" : "",
};
} else {
if (!presets.hasOwnProperty('Duration')) {
presets['Duration'] = "";
}
}
} else {
var presets = {
"Title" : "",
"Store" : "",
"Shipping Weight" : "",
"Display Weight" : "",
"Location" : "",
"Duration" : "",
"Starting Bid" : "",
"BIN Price" : "",
"Ship Charge" : "",
"Ship Type" : "",
// ^^^ general, guitar, art, lot, long, Media <---- note the capital M!
"Ship in own box/between cardboard" : "",
// ^^^ yes for yes, any other value defaults to no
"Dimension 1" : "",
"Dimension 2" : "",
"Dimension 3" : "",
"Skip" : "",
"Owner" : thisPoster,
"Cyber Monday" : "",
};
}
if(presets['Skip'] == 'skip' || presets['Cyber Monday'].toLowerCase() == 'skip' || presets['Cyber Monday'].toLowerCase() == 'yes') {
console.log('Skip==skip');
if (url.indexOf('newauctionitem-catsel.asp')) {
document.getElementById('form1').action = document.getElementById('form1').action + '?skip=skip';
}
} else if (url.indexOf('?skip=skip') >= 0) {
$('input[name="submit"]').trigger('click');
}
var myPresets = "";
var presetBox = "Set presets:
";
$('p:contains("photos are uploaded")').after(presetBox);
$.each(presetTypes, function(key, value){
var myVal = presets[key];
if (typeof myVal == 'undefined' || myVal == 'undefined' || myVal.length < 1) {
myVal = '';
}
if (myVal && myVal.length) {
myPresets += "" + key + ": " + myVal + "
";
}
key2 = "" + key + ""
if (key == 'Ship Type') {
key2 += " (guitar, art, long, media, clothing, pickup)";
} else if (key == "Ship in own box/between cardboard") {
key2 = "Own box/cardboard: (yes or blank/no)";
}
key2 += ": ";
$('#presetBox').append("" + key2 + "
");
});
$('#presetInputOwner').hide();
if (myPresets.length) {
myPresets = "Presets:
" + myPresets + "
";
$('#presetBox').before(myPresets);
$('#myPresets').data("data", presets);
}
if(myPresets['Ship Type'] == "media") {
myPresets['Ship Type'] = "Media";
}
$('#presetBox').append("
Update presets");
$('#presetBox').after("
Edit presets");
$('#presetLocation').attr('id', 'tempLoc');
$('#tempLoc').after("");
$('#tempLoc').remove();
$('#presetLocation').append("");
$.each(jsondata2, function(shelfIndex, shelfArray){
$('#presetLocation').append("");
});
$('#presetStore').attr('id', 'tempStore');
$('#tempStore').after($('#itemsellerstore').clone().attr('id', 'presetStore'));
$('#tempStore').remove();
$('#presetStore').prepend("");
if(url == "https://sellers.shopgoodwill.com/sellers/newAuctionItem-catsel.asp?clear=yes") {
// Hides form if photos are not uploaded
// the return URL from the photo uploader is:
// https://sellers.shopgoodwill.com/sellers/newauctionitem-catsel.asp?btnSubmit=Return+to+item+entry
$('#form1').hide();
} else if (url != "https://sellers.shopgoodwill.com/sellers/reviewItem-label.asp") {
$('#itemTitle').parent().parent().prepend("");
$('#listingUpgrades').append("Gallery ($8) | ");
$('#listingUpgrades').append("Feature ($5) | ");
$('#listingUpgrades').append("Premium item | ");
$('#listingUpgrades').parent().append("| Duration: (ends on a ) |
");
$('#listingUpgrades').parent().append("| Starting Price: |
");
}
//$("#form1").append("");
$("#form1").append("false
");
//$("#form1").append("");
var button1 = "');
$('#itemShipMethod').before('');
$('#itemShipMethod').after("
" + button1 + "Unlock shipping method" + button2 + "
");
}
var currentDur = $('#itemDuration').val();
if (url != "https://sellers.shopgoodwill.com/sellers/newauctionitem-catsel.asp?btnSubmit=Return+to+item+entry" && url != "https://sellers.shopgoodwill.com/sellers/reviewItem-label.asp") {
$('#itemDuration').replaceWith("");
}
var cmAllow = "no";
var cmBIN = "no";
$("#itemStartOffset, #itemstarttime, #itemDuration, #itemEndTime, #itemShipMethod, #itemShippingPrice, #itemNoCombineShipping, #itemAutoInsurance").attr('tabindex', "-1");
$("#WebWizRTE, #itemDescription").height(700);
$("#WebWizRTE, #itemDescription").width(810);
$("#s1").attr("size", 100);
$("strong:contains('Item Title')").prepend("
");
$("#itemTitle").attr("maxlength",50);
$("#itemTitle").removeAttr('onkeypress').removeAttr('onkeyup');
$('#myCounter').html(50);
//UGH, SHOPGOODWILL
$('font:contains("Numbers and decimal point")').after("
" + button1 + "Unlock shipping charge" + button2 + "
");
$('strong:contains("Private Description")').hide();
$('#itemSellerInfo').hide();
$('p:contains("optimization")').hide();
var html = $('#form1 > table > tbody > tr:eq(1) > td:eq(1)')[0];
var html2 = $('#form1 > table:eq(1) > tbody > tr > td')[0];
html2.innerHTML = html2.innerHTML.replace(/You will be advised[\s\S]*place your listing[\s\S]*will be assessed[\s\S]*in the next screen\./g,"");
$("p:contains('Make sure you know')").hide();
$("p:contains('Please review the')").hide();
$("p:contains('read shopgoodwill')").hide();
$("hr").hide();
$('p:contains("Starting Bid")').addClass("bidStartDurBox");
$('p:contains("Auction Duration")').addClass("bidStartDurBox").after("
");
$('p:contains("Auction Duration")').after("Starting bid, start time, duration
")
$('#bidStartDurBoxButton').after("Buy now price");
$('.bidStartDurBox').hide();
$('#itemStartOffset').attr("id", "itemStartOffset");
$('#itemstarttime').attr("id", "itemstarttime");
$('#itemDuration').attr("id", "itemDuration");
html.innerHTML = html.innerHTML.replace("onblur", "alt");
html.innerHTML = html.innerHTML.replace(/
/g,"");
html.innerHTML = html.innerHTML.replace(/pounds((.|\n)*)oversized packages\./g,"");
html.innerHTML = html.innerHTML.replace(/Shipping Charge allows((.|\n)*)United States\./g,"");
$('b:contains("Set the Shipping Charge")').hide();
html.innerHTML = html.innerHTML.replace(/to use the default shipper's rate calculator\./g,"");
html.innerHTML = html.innerHTML.replace(/This is the number((.|\n)*)become active\./g,"");
html.innerHTML = html.innerHTML.replace(/This is the number((.|\n)*)will end\./g,"");
$('font:contains("UPS dimensional weight calculator click")').hide();
html.innerHTML = html.innerHTML.replace(/Select this option to change the shipping method from your default method\./g,"");
html.innerHTML = html.innerHTML.replace(/One line((.|\n)*)find your item\.|You may use((.|\n)*)do not use HTML\.|For |Dutch auctions((.|\n)*)selling a single set\.|This is the price((.|\n)*)and commas \(','\)|Bid increment is((.|\n)*)each bid\.|Reserve Price is((.|\n)*)Reserve Price!|Buy Now allows((.|\n)*)Buy Now!/g, "");
html.innerHTML = html.innerHTML.replace(/Item Quantity((.|\n)*)itemQuantity" size="3" value="1">/g, "");
html.innerHTML = html.innerHTML.replace(/per item((.|\n)*): 3\.00/g, "");
html.innerHTML = html.innerHTML.replace(/Bid Increment((.|\n)*)10\.00/g, "Bid increment:
Reserve price:
Buy now price: (leave at 0 to not have buy-it-now as an option)
Starting bid = BIN price");
html.innerHTML = html.innerHTML.replace(/Box Selection((.|\n)*)willing to ship your item\./g, "")
html.innerHTML = html.innerHTML.replace(/Handling Charge((.|\n)*)final item selling price\)\./g, "");
html.innerHTML = html.innerHTML.replace(//g, "");
html.innerHTML = html.innerHTML.replace(/Example: 1<\/i>/g, "");
html.innerHTML = html.innerHTML.replace(/here<\/a>/g, "here");
html.innerHTML = html.innerHTML.replace(/here<\/a>/g, "here");
html.innerHTML = html.innerHTML.replace(/