// ==UserScript==
// @name SGW Fixer - Dev
// @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 http://localhost/sgw.html
// @version 6.4.0.1
// @description Implements numerous improvements to the functionality of the Shopgoodwill seller site.
// @grant none
// @require https://greasyfork.org/scripts/10208-gm-api-script/code/GM%20API%20script.js?version=54964
// @require https://greasyfork.org/scripts/19381-sgw-shelves-cats/code/SGW%20Shelves%20%20Cats.user.js?version=126258
// @downloadURL none
// ==/UserScript==
$('*[name]').not('[id]').each(function(){
$(this).attr('id', $(this).attr('name'));
});
window.addEventListener ("message", receiveMessage, false);
var url = document.URL;
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'] + "
");
$('p').first().before("
" + myLastLoc['lastTitle'] + "
");
GM_deleteValue("lastLocation");
}
}
if (GM_getValue("lastLocation")) {
myLastLoc = JSON.parse(GM_getValue("lastLocation", ""));
// console.log(url + ": Last location stored as " + myLastLoc['lastLocation']);
// console.log(url + ": Last title: " + myLastLoc['lastTitle'])
}
// 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)
// "buttonLock" : "yes" causes the shipping buttons to have a lock over them for that user
// "unlockY" : [number] is an optional argument that allows you to set the height of the unlock button (with icon): a larger number makes the
// button lower on the page
var posters = {
"Alicia V" : {
"name" : "Alicia",
// "delay" : 1,
},
"Hetal S" : {
"name" : "Hetal",
"duration" : 4,
"delay" : 0,
},
"Jacob L" : {
"name" : "Jacob",
"skip" : "allow",
"CM" : "yes",
"delay" : 0,
"duration" : 4,
"debug" : true,
},
"Jackie C" : {
"name" : "Jackie",
"CM" : "yes",
"delay" : 0,
"duration" : 4,
},
"Jeff H" : {
"name" : "Jeff",
"skip" : "allow",
"CM" : "BIN",
"delay" : 0,
"duration" : 4,
"debug" : true,
},
"Jeremy J" : {
"name" : "Jeremy",
"skip" : "allow",
"duration" : 4,
"CM" : "yes",
"delay" : 0,
"debug" : true,
},
"Jessica G" : {
"name" : "Jessica",
"delay" : 0,
},
"Joanne H" : {
"name" : "Joanne",
"delay" : 0,
},
"Kathy O" : {
"name" : "Kathy",
"skip" : "allow",
"delay" : 0,
"duration" : 4,
},
"Nick Q" : {
"name" : "Nick",
"delay" : 0,
},
"Phalada X" : {
"name" : "Phalada",
"skip" : "allow",
"CM" : "yes",
"delay" : 0,
"duration" : 4,
},
"Peter N" : {
"name" : "Peter",
"delay" : 0,
},
"Phillip S" : {
"name" : "Phillip",
"delay" : 0,
},
"Poppy P" : {
"name" : "Poppy",
"delay" : 0,
"debug" : true,
},
"Tanya K" : {
"name" : "Tanya",
"delay" : 0,
},
"Thomas L Butler" : {
"name" : "Tom",
"delay" : 0,
},
"Valerie W" : {
"name" : "Valerie",
"duration" : 4,
"skip" : "allow",
"CM" : "yes",
"delay" : 0,
"debug" : true,
},
}
var thisPoster = "";
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,"");
console.log(thisPoster);
}
});
var presetTypes = {
"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" : "",
}
$('body').append('');
if (GM_getValue("storedPresets")) {
var presets = JSON.parse (GM_getValue("storedPresets"));
if (!presets.hasOwnProperty('Owner') || presets['Owner'] != thisPoster) {
if(presets['Skip'] == 'skip') {
// console.log('Skip==skip');
$("head").append("");
} else {
}
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,
};
} else {
if (!presets.hasOwnProperty('Duration')) {
presets['Duration'] = "";
} else {
}
if(presets['Skip'] == 'skip') {
$("head").append("");
} else {
// console.log('Skip!=skip');
}
}
} else {
var 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,
};
}
var myPresets = "";
var presetBox = "Set presets:
";
$('p:contains("photos are uploaded")').after(presetBox);
$.each(presetTypes, function(key, value){
var myVal = presets[key];
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 {
$('#presetBoxButton').parent().append("Gallery:
");
}
$("#form1").append("");
$("#form1").append("false
");
var button1 = "');
$('#itemShippingPrice').before('');
$('#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") {
$('#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");
// Cyber Monday buttons
/*
now = new Date();
currentDate = now.getDate();
cyberMondayStart = 20;
daysTillCMStart = cyberMondayStart - currentDate;
cyberMonday = 30;
daysTillCM = cyberMonday - currentDate;
if (cmAllow == "yes") {
$('#BINBoxShowButton').after("
Cyber Monday");
if (daysTillCMStart > 0) {
/// $('#cyberMondayDurButton').after(" Cyber Monday (pre-post)");
}
if (cmBIN == "yes") {
$('#cyberMondayDurButton').after(" Cyber Monday BIN");
}
}
*/
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)");
// html.innerHTML = html.innerHTML.replace(//g, "");
// html.innerHTML = html.innerHTML.replace(//g, "");
// $("input[name='itemTitle']").attr("required", true);
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(//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(/