Jump to content

Run JavaScript on Safari


Recommended Posts

Is there a way to run a specific JavaScript through Alfred in the safari window you're looking at?

 

The script address is 

"javascript:const%20q=escape(location.href);location.href=%60https://papago.naver.net/website?locale=ko&source=auto&target=ko&url=$%7Bq%7D%60"
It is.

Link to comment

You need to remove the javascript: scheme and URL-decode it:

const q=escape(location.href);location.href='https://papago.naver.net/website?locale=ko&source=auto&target=ko&url='+q;


The full AppleScript to run that JS in the active tab is therefore:

tell application "Safari" to do JavaScript "const q=escape(location.href);location.href='https://papago.naver.net/website?locale=ko&source=auto&target=ko&url='+q;" in front document

 

Edited by deanishe
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...