aboutsummaryrefslogtreecommitdiff
path: root/usps/fill-out-usps-scheduled-pickup.js
diff options
context:
space:
mode:
authorTimmy Keller <tjk@tjkeller.xyz>2024-08-10 19:34:54 -0500
committerTimmy Keller <tjk@tjkeller.xyz>2024-08-10 19:34:54 -0500
commit5cd7617d4467693feced81b440eee8782aebdb02 (patch)
tree68a854bc69f9ee16eedd82d83fb0d091795f6bc4 /usps/fill-out-usps-scheduled-pickup.js
downloaduserscripts-5cd7617d4467693feced81b440eee8782aebdb02.tar.xz
userscripts-5cd7617d4467693feced81b440eee8782aebdb02.zip
initial commit
Diffstat (limited to 'usps/fill-out-usps-scheduled-pickup.js')
-rw-r--r--usps/fill-out-usps-scheduled-pickup.js107
1 files changed, 107 insertions, 0 deletions
diff --git a/usps/fill-out-usps-scheduled-pickup.js b/usps/fill-out-usps-scheduled-pickup.js
new file mode 100644
index 0000000..88660fc
--- /dev/null
+++ b/usps/fill-out-usps-scheduled-pickup.js
@@ -0,0 +1,107 @@
+// ==UserScript==
+// @name Fill out usps scheduled pickup
+// @namespace Violentmonkey Scripts
+// @match https://tools.usps.com/schedule-pickup-steps.htm*
+// @grant none
+// @version 1.0
+// @author -
+// @description 2/11/2024, 7:23:34 PM
+// ==/UserScript==
+
+/* First page config */
+const fill = {
+ emailAddress: "youremail@example.com",
+ phoneNumber: "777-777-7777",
+ zipCode: "60606",
+ state: "IL",
+ city: "CHICAGO",
+ addressLineOne: "701 My Lovely Home St.",
+ lastName: "Smith",
+ firstName: "John"
+}
+
+/* Misc config */
+const packageLocationFill = "Porch"
+
+/* Fill funcs */
+function fillInitialFields() {
+ for (let fieldName in fill)
+ document.getElementById(fieldName).value = fill[fieldName]
+}
+
+function fillDogField() {
+ const f = document.querySelector("#second-radio-verification[name=isDogHere]")
+ f.checked = true
+ return f
+}
+
+function fillPackageLocation() {
+ const f = document.getElementById("packageLocation")
+ f.value = packageLocationFill
+ return f
+}
+
+function fillPickupTime() {
+ const f = document.getElementById("pickup-regular-time")
+ f.click()
+ return f
+}
+
+function fillPickupDate() {
+ const f = document.querySelector("#schedule-pickup-cal td:not(.ui-datepicker-unselectable)") // Gets first date that is selectable
+ f.click()
+ return f
+}
+
+function fillTerms() {
+ const f = document.querySelector(".termsConditions")
+ f.checked = true
+ return f
+}
+
+function fillHazmat() {
+ const f = document.querySelector("#hazmat-no")
+ f.checked = true
+ return f
+}
+
+function scrollToDetails() {
+ document.getElementById("quantityCheck").scrollIntoView()
+}
+
+function showPickupDateInStepFour(pickupDateTD) {
+ const month = parseInt(pickupDateTD.dataset.month) + 1
+ const year = pickupDateTD.dataset.year
+ const day = pickupDateTD.firstElementChild.innerText
+
+ const date = `${month}-${day}-${year}`
+
+ const dateElement = document.createElement("div")
+ dateElement.class = "step-four-top-header"
+ dateElement.innerHTML = `<p class="step-four-row-header"></p>`
+ dateElement.innerHTML += `<p class="step-four-row-header" style="font-weight:bold;">Date of Pickup: ${date}</p>`
+
+ const container = document.querySelector("div.pickup-summary-gray-box-wrapper div")
+ const sibiling = container.querySelector("div.step-four-top-header")
+ container.insertBefore(dateElement, sibiling)
+ return dateElement
+}
+
+/* Start */
+fillInitialFields()
+
+document.querySelector("#webToolsAddressCheck").addEventListener("click", () => {
+ const magicChange = new Event("change")
+
+ fillDogField() .dispatchEvent(magicChange)
+ fillPackageLocation().dispatchEvent(magicChange)
+
+ fillPickupTime() // Works through click
+
+ setTimeout(() => {
+ showPickupDateInStepFour(fillPickupDate()) // Need to wait for this (calendar) to load in first since it's loaded dynamically
+ fillHazmat()
+ fillTerms()
+ scrollToDetails()
+ }, 750)
+})