Script is switching out of the browser window after it completes.


Joined
Jan 10, 2021
Messages
2
Reaction score
0
I have a script that was written for me that strips reference info from links that I need to post. When it's done, it somehow switches to a different browser window. Not all the time though, and I can't quite pinpoint what triggers it.
Is there a way to force it to stay in the same browser window that it started in?

Thank you!!
 
Ad

Advertisements

Ad

Advertisements

Joined
Jan 10, 2021
Messages
2
Reaction score
0
Here is what I have... and I think it forces a window that was opened after the active window to be the active window. But I can't tell. I just need it to stay put! LOL!

Thanks so much for your help!!




tell application "Google Chrome"


set theUrl to URL of active tab of window 1


set splitCharacters to "ref"


set splitOffset to (offset of splitCharacters in theUrl) + (count splitCharacters) - 4


set newURL1 to text 1 thru splitOffset of theUrl


set AppleScript's text item delimiters to "p/"


set itemNumber to text item 2 of newURL1


set newUrl to "https://www.amazon.com/dp/" & itemNumber


set the clipboard to newUrl


--return newUrl


set URL of active tab of window 1 to newUrl


end tell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top