// ==UserScript==
// @name E-Comm Shipping Calculator
// @namespace https://greasyfork.org
// @include https://sellers.shopgoodwill.com/sellers/newAuctionItem-catsel.asp*
// @include https://sellers.shopgoodwill.com/sellers/modifyItem.asp*
// @include *info*center/shipping.html*
// @version 2.1.5.2
// @description Implements a shipping calculator on the current page.
// @grant none
// @downloadURL none
// ==/UserScript==
// These are editable! Format is as follows:
//
// "Button name" : price,
//
// Important notes:
// 1. Name MUST be in quotation marks.
// 2. A comma MUST follow the price,
var url = document.URL;
if (url.indexOf('info*center/shipping.html') > 0) {
$('body').children().remove();
}
$('head').append('');
$('body').append("
");
var minimumWeight = 3; // This is the minimum weight we'll charge.
upsDivisor = 225;
var shippingMethods = {
"Sm flat rate box" : {
"price" : 6.80,
"note" : "Small flat rate box",
"method" : "USPS",
"tooltip" : "Interior dimensions: 5x8.5x1.5 - NOTE: remember room for packing material!",
},
"Bubble mailer" : {
"price" : 6.80,
"note" : "Bubble mailer",
"tooltip" : "Bubble mailers are padded, but consider if your item needs extra padding as well.",
"method" : "USPS"
},
"Med flat rate box" : {
"price" : 13.00,
"note" : "Medium flat rate box",
"method" : "USPS",
"tooltip" : "Interior dimensions: 12x13.5x3.5 OR 11x8.5x5.5 - NOTE: remember room for packing material!"
},
"Media" : {
"note" : "Media",
"tooltip" : "Any: book; movie (VHS, DVD, Blu-Ray, laserdisc, film reel); music (record, 8-track, tape, CD) - regardless of size or weight. NOT comic books, magazines, newspapers, or video games.",
"method" : "USPS"
},
/* "Lt clothing" : {
"price" : 4.99,
"note" : "Poly-mailer",
"tooltip" : "Poly-mailer. Use if a clothing item is light - like a t-shirt.",
"method" : "USPS"
},
"Med clothing" : {
"price" : 6.99,
"note" : "Poly-mailer",
"tooltip" : "Poly-mailer. Use if a clothing item is a bit heavier - like a pair of jeans.",
"method" : "USPS"
},*/
"Clothing" : {
"note" : "Clothing",
"tooltip" : "Clothing, excluding e.g. largeish coats",
},
"Sm guitar box" : {
"note" : "6x18x44 guitar box",
"tooltip" : "Interior dimensions: 6x18x44; shipping weight: " + Math.ceil((7*19*45)/upsDivisor),
"weight" : Math.ceil((7*19*45)/upsDivisor),
"method" : "UPS"
},
"Lg guitar box" : {
"note" : "8x20x50 guitar box",
"tooltip" : "Interior dimensions: 8x20x50; shipping weight: " + Math.ceil((9*21*51)/upsDivisor),
"weight" : Math.ceil((9*21*51)/upsDivisor),
"method" : "UPS"
},
"Sm print box" : {
"note" : "5x24x30 print box",
"tooltip" : "Interior dimensions: 5x24x30; shipping weight: " + Math.ceil((6*24*31)/upsDivisor),
"weight" : Math.ceil((6*24*31)/upsDivisor),
"method" : "UPS"
},
"Lg print box" : {
"note" : "5x30x36 print box",
"tooltip" : "Interior dimensions: 5x30x36; shipping weight: " + Math.ceil((6*31*37)/upsDivisor),
"weight" : Math.ceil((6*31*37)/upsDivisor),
"method" : "UPS"
},
/* "Huge print box" : {
"note" : "5.5x36x48 print box",
"tooltip" : "Interior dimensions: 5.5x36x48; shipping weight: " + Math.ceil((7*37*49)/upsDivisor),
"weight" : Math.ceil((7*37*49)/upsDivisor),
"method" : "UPS"
},*/
/* "8x8 long box" : {
"note" : "8x8 long box",
"tooltip" : "Interior dimensions: 8x8x?",
"method" : "UPS"
},
"12x12 long box" : {
"note" : "12x12 long box",
"tooltip" : "Interior dimensions: 8x8x?",
"method" : "UPS"
},*/
"Sm coat box" : {
"note" : "9x12x12 coat box",
"tooltip" : "Interior dimensions: 9x12x12; shipping weight: " + Math.ceil((10*13*13)/upsDivisor),
"weight" : Math.ceil((10*13*13)/upsDivisor),
"method" : "UPS"
},
"Med coat box" : {
"note" : "6x14x18 coat box",
"tooltip" : "Interior dimensions: 6x14x18; shipping weight: " + Math.ceil((7*15*19)/upsDivisor),
"weight" : Math.ceil((7*15*19)/upsDivisor),
"method" : "UPS"
},
"Very lg coat box" : {
"note" : "10x14x18 coat box",
"tooltip" : "Interior dimensions: 10x14x18; shipping weight: " + Math.ceil((11*15*19)/upsDivisor),
"weight" : Math.ceil((11*15*19)/upsDivisor),
"method" : "UPS"
},
"Standard sm UPS box" : {
"note" : "6.25x7.25x10.25 small box",
"tooltip" : "Interior dimensions: 6.25x7.25x10.25; shipping weight: " + Math.ceil((7*8*11)/upsDivisor),
"weight" : Math.ceil((7*8*11)/upsDivisor),
"method" : "UPS",
},
"Small&light" : {
"price" : 2.99,
"note" : "Game/cards",
"tooltip" : "One or two small games (or several Gameboy games), a small stack of cards, an iPod... err on the side of checking with shipping!",
"method" : "USPS",
},
/* "Sew mchn w/case" : {
"note" : "20x14x18 box",
"tooltip" : "Interior dimensions: 14x18x20; shipping weight: " + Math.ceil((15*19*21)/upsDivisor),
"weight" : Math.ceil((15*19*21)/upsDivisor),
"method" : "UPS",
},
"Sew mchn, no case" : {
"note" : "10x14x18 box",
"tooltip" : "Interior dimensions: 10x14x18; shipping weight: " + Math.ceil((11*15*19)/upsDivisor),
"weight" : Math.ceil((11*15*19)/upsDivisor),
"method" : "UPS",
}*/
};
// This next section sets up our default boxes.
// It's CRITICALLY IMPORTANT that the dimensions for these boxes get listed in ascending order (e.g. 8, 17, 36).
// "Interior" is the interior dimensions of the box - how large an item can fit inside. "Exterior" is the set of dimensions used to calculate the weight.
// The reason that these are defined separately is so that we can require a varying amount of padding per dimension and per box.
var guitarBoxes = {
"default" : {
0 : 7,
1 : 16,
2 : 35
/* The interior/exterior doesn't matter here: the default "box" is used to decide "this doesn't need to go in a special box, and should be treated like a regular item". */
},
"boxes" : {
1 : {
"interior" : {
0 : 6,
1 : 17,
2 : 42,
},
"exterior" : {
0 : 7,
1 : 19,
2 : 45
},
"name" : "Small guitar box",
"corresponds" : "Sm guitar box"
},
2 : {
"interior" : {
0 : 8,
1 : 20,
2 : 48
},
"exterior" : {
0 : 9,
1 : 21,
2 : 51
},
"name" : "Large guitar box",
"corresponds" : "Lg guitar box"
}
}
};
var artBoxes = {
"default" : {
0 : 5,
1 : 17,
2 : 19
},
"boxes" : {
1 : {
"interior" : {
0 : 3,
1 : 23,
2 : 23
},
"exterior" : {
0 : 5,
1 : 25,
2 : 25
},
"name" : "Small print box",
"corresponds" : "Sm print box"
},
2 : {
"interior" : {
0 : 4,
1 : 23,
2 : 29
},
"exterior" : {
0 : 6,
1 : 25,
2 : 31
},
"name" : "Medium print box",
"corresponds" : "Med print box"
},
3 : {
"interior" : {
0 : 4,
1 : 29,
2 : 35
},
"exterior" : {
0 : 6,
1 : 31,
2 : 37
},
"name" : "Large print box",
"corresponds" : "Lg print box"
},
/* 4 : {
"interior" : {
0 : 4,
1 : 33, // are these dimensions right???
2 : 45
},
"exterior" : {
0 : 6,
1 : 36,
2 : 48
},
"name" : "Huge print box",
"corresponds" : "Huge print box"
},*/
}
};
var generalBoxes = [
{
"interior" : [
8,
8.75,
11.25
],
"name" : "11.25x8.75x8",
"cut" : "1",
},
{
"interior" : [
9,
12,
12
],
"name" : "12x12x9",
"cut" : "0",
},
{
"interior" : [
5,
18,
24
],
"name" : "24x5x18",
"cut" : "1",
},
{
"interior" : [
10,
14,
18
],
"name" : "18x14x10",
"cut" : "0",
},
{
"interior" : [
5,
24,
24
],
"name" : "24x5x24",
"cut" : "2",
},
{
"interior" : [
8,
8,
60
],
"name" : "8x8x48",
"cut" : "2",
},
{
"interior" : [
5,
24,
30
],
"name" : "30x5x24",
"cut" : "1",
},
{
"interior" : [
14,
16,
20
],
"name" : "20x16x14",
"cut" : "0",
},
{
"interior" : [
6,
18,
48
],
"name" : "18x6x45",
"cut" : "2",
},
{
"interior" : [
14,
18,
20
],
"name" : "20x14x18",
"cut" : "1",
},
{
"interior" : [
12,
12,
36
],
"name" : "36x12x12",
"cut" : "1",
},
{
"interior" : [
5,
30,
36
],
"name" : "36x5x30",
"cut" : "1",
},
{
"interior" : [
12,
12,
60
],
"name" : "12x12x40",
"cut" : "2",
},
{
"interior" : [
8,
20,
50
],
"name" : "20x8x50",
"cut" : "2",
},
{
"interior" : [
5.5,
36,
40
],
"name" : "36x5.5x40",
"cut" : "2",
},
{
"interior" : [
10,
12,
22
],
"name" : "22x12x10",
"cut" : "0",
},
];
$.each(generalBoxes, function(){
this.exterior = [
Math.ceil(this.interior[0]+1),
Math.ceil(this.interior[1]+1),
Math.ceil(this.interior[2]+1),
]
});
$('body').append('');
var uspsBoxes = {
"smallFlat1" : {
/* Because these are billed at a flat rate, they also don't need two separate sets of dimensions. All we need to know is if the item will fit. */
0 : 1.25,
1 : 4.75,
2 : 8.25,
"name" : "small ($6.80) flat rate box",
"corresponds" : "Sm flat rate box",
"price" : "6.80",
},
/* "medFlat1" : { // The shipping calculator is no longer going to suggest
0 : 3.25, // medium flat-rate boxes, as UPS seems to universally be
1 : 11.75, // cheaper.
2 : 13.25,
"name" : "medium ($13.00) flat rate box",
"corresponds" : "Med flat rate box",
"price" : "13.00",
},
"medFlat2" : {
0 : 5.25,
1 : 8.25,
2 : 10.75,
"name" : "medium ($13.00) flat rate box",
"corresponds" : "Med flat rate box",
"price" : "13.00",
},*/
};
$("body").prepend("");
var shippingOptions = "";
var buttonCount = 0;
$.each( shippingMethods, function( key, value ) {
shippingOptions = shippingOptions + "