greedist Posted April 18, 2021 Posted April 18, 2021 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.
deanishe Posted April 18, 2021 Posted April 18, 2021 Safari lets you run JS in a tab via AppleScript: tell application "Safari" to do JavaScript "alert('script!')" in front document It expects proper JavaScript, though, not a javascript: URI
greedist Posted April 19, 2021 Author Posted April 19, 2021 It worked when you clicked on the JavaScript as a favorite, but it didn't work with AppleScript. How do I change JavaScript url? Please help me..
deanishe Posted April 19, 2021 Posted April 19, 2021 (edited) 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 April 19, 2021 by deanishe greedist 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now