Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nyc fresh multiple days #48

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 40 additions & 2 deletions delivery-window-finder.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ set unknown_page_msg to "Unknown amazon page was loaded. try to manually navigat
set slot_site_url to "https://www.amazon.com/gp/buy/shipoptionselect/handlers/display.html?hasWorkingJavascript=1"
set slot_page_keyword to "Schedule your order"
set no_slot_keyword to "No delivery windows available"
set no_doorstep_slot_keyword to "No doorstep delivery windows are available"
set no_attended_slot_keyword to "No attended delivery windows are available"
set is_first_run to true
set auto_ignore_oos to true

Expand Down Expand Up @@ -229,16 +231,52 @@ if javascriptEnabled then
end if

-- wait for the page to load
delay 30
delay 10

-- get the text on the page
set siteText to (text of last tab of window id amzn_win_id) as string
end tell

-- click on tomorrow
clickClassName("a-button-text", 11, -1, amzn_win_id)

delay 10

tell application "Safari"

set siteText2 to (text of last tab of window id amzn_win_id) as string

end tell


-- click on 2 days later
clickClassName("a-button-text", 12, -1, amzn_win_id)

delay 10

tell application "Safari"

set siteText3 to (text of last tab of window id amzn_win_id) as string

end tell


-- click on 3 days later
clickClassName("a-button-text", 13, -1, amzn_win_id)

delay 10

tell application "Safari"

set siteText4 to (text of last tab of window id amzn_win_id) as string

end tell


-- PROCESS PAGE CONTENTS:

-- no delivery slots available
if siteText contains no_slot_keyword then
if ((siteText contains no_slot_keyword) or (siteText contains no_doorstep_slot_keyword) or (siteText contains no_attended_slot_keyword)) and ((siteText2 contains no_slot_keyword) or (siteText2 contains no_doorstep_slot_keyword) or (siteText2 contains no_attended_slot_keyword)) and ((siteText3 contains no_slot_keyword) or (siteText3 contains no_doorstep_slot_keyword) or (siteText3 contains no_attended_slot_keyword)) and ((siteText4 contains no_slot_keyword) or (siteText4 contains no_doorstep_slot_keyword) or (siteText4 contains no_attended_slot_keyword)) then

-- closes the tab since no slot was found
tell application "Safari"
Expand Down
Binary file modified delivery-window-finder.scpt
Binary file not shown.