emilstahl

MacBay Safari Service

Nov 6th, 2013
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (*
  2. Skift selv ud hvis i bruger andet end Safari
  3. # Google Chrome
  4. tell application "Google Chrome" to return URL of active tab of front window
  5. tell application "Google Chrome" to return title of active tab of front window
  6. # Google Chrome Canary
  7. tell application "Google Chrome Canary" to return URL of active tab of front window
  8. tell application "Google Chrome Canary" to return title of active tab of front window
  9. # Chromium
  10. tell application "Chromium" to return URL of active tab of front window
  11. tell application "Chromium" to return title of active tab of front window
  12. # Safari
  13. tell application "Safari" to return URL of front document
  14. tell application "Safari" to return name of front document
  15. # Webkit
  16. tell application "Webkit" to return URL of front document
  17. tell application "Webkit" to return name of front document
  18.  
  19. https://gist.github.com/vitorgalvao/5392178#file-get_title_and_url-applescript
  20. *)
  21.  
  22. tell application "Safari"
  23.     set theURL to URL of front document
  24.     set theTitle to get name of document 1
  25.     set selectedText to (do JavaScript "(''+getSelection())" in document 1)
  26.     if selectedText = "" then
  27.         set citat to ""
  28.     else
  29.         set citat to "[citat]" & selectedText & "[/citat]" & return
  30.     end if
  31.     set the clipboard to citat & "[link=" & theURL & "]" & theTitle & "[/link]" as string
  32. end tell
Advertisement
Add Comment
Please, Sign In to add comment