SUMMARY:
How can I redirect domain to a different domain?
For example, if **www.siteA.com/**something/anything&r=%2Ftitle loads, auto redirect to **www.siteB.com/**something/anything&r=%2Ftitle
I if siteA tried to load content, replace siteA with siteB and load the content. Everything after .com/ could change.
I have the following partially working:
on run
tell application "Safari" to launch
end run
on idle
if application "Safari" is not running then quit me
tell application "Safari" to tell window 1
try
set tnet to (tabs whose URL starts with "https://t-net.siteA.com/")
delay 0.1
if tnet is not {} then
set URL of item 1 of tnet to "https://t-net.siteB.com/"
end if
end try
end tell
if application "Safari" is not running then quit me
return 0.5
end idle
on quit
continue quit -- allows the script to quit
end quit
To really make this work, I also need to have the script change/replace just the root domain, and keep everything after .com/ maybe using some sort of wildcard regex type approach?
Or, I need to get everything after .com/, copy it, and then append it to the redirect URL?
Note to anyone playing with this idea, the AppleScript must be saved as an Application. Also, in Safari, Developer Mode must be enables via Preferences > Advanced. Then in Safari, go to Develop (menu) > All JavaScript from Apple Events to turn it on.