Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Save selected browser text via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Save selected browser text via AppleScript
Authored by: MrLucky on Feb 15, '08 10:26:46AM

Very elegant script. I've been using something similar, so I cannibalized bits of this one and put them into mine. I collect loads of news clippings, so my script copies the selected text to a unique document, saved as the first line of the selection (i.e. Man Bites Dog.txt).

tell application "Finder" to set dFolder to ((startup disk) as string) & "" --write the path to your preferred folder between these quotes, using colons to separate the folder names, i.e. Users:username:Documents:MyNewsClippings:

tell application "Safari"
set selecTxt to (do JavaScript "(getSelection())" in document 1)
set theurl to (get URL of document 1)
set pgTitl to (do JavaScript "document.title" in document 1)
end tell
set tSubject to first paragraph of (selecTxt as string)
if (tSubject contains ":") then
set {oAStid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ":"}
set tSubject to text items of tSubject
set AppleScript's text item delimiters to "_"
set tSubject to tSubject as string
set AppleScript's text item delimiters to oAStid
end if
set dat to (current date) as text
set tContent to pgTitl & return & theurl & return & dat & return & return & selecTxt
set fRef to open for access file (dFolder & tSubject & ".txt") with write permission
write tContent as string to fRef
close access fRef
tell application "Safari" to activate


To use this effectively, highlight the text in Safari, such that the title of the article is the first line. The resulting .txt file will appear in your preferred folder with the filename set as the first line of selected text. I uses Fastscripts to run this one with a keystroke.



[ # ]
Save selected browser text via AppleScript
Authored by: amaloney on Mar 01, '08 08:16:59PM

MrLucky

How does one do this with Firefox?

Al Maloney



[ # ]