------------------------------------------------------------------------------------------------
on dateStr()
tell (current date)
set d to (its month as number) & (its day as number) & (its year) mod (((its year) div 1000) * 1000)
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
set d to d as text
set AppleScript's text item delimiters to oldTIDS
return d
end tell
end dateStr
------------------------------------------------------------------------------------------------
on winBounds(percentScreenWidth)
tell application "Finder" to set {x1, y1, x2, y2} to bounds of window of desktop
set winWidth to (percentScreenWidth * x2) div 1
set newX1 to (x2 - winWidth) div 2
set newX2 to newX1 + winWidth
set newBounds to {newX1, 44, newX2, y2}
return newBounds
end winBounds
------------------------------------------------------------------------------------------------
tell application "Safari"
if front document exists then
tell front document
set theURL to its URL
set pageText to its text
end tell
end if
end tell
------------------------------------------------------------------------------------------------
set pageHdr to dateStr() & return & return & theURL & return & return
------------------------------------------------------------------------------------------------
tell application "BBEdit"
activate
set newDoc to make new document with properties {text:pageText}
set bounds of front window to winBounds(0.5) of me
tell newDoc
tell its text
straighten quotes with replacing target
replace "\\A\\s+" using
"" options {search mode
:grep, starting at top
:true} replace "\\s{2,}\\Z" using
return
options {search mode
:grep, starting at top
:true} replace linefeed using return options {starting at top:true}
set before character 1 to pageHdr
select insertion point before character 1
end tell
tell its window
if soft wrap text = false then
set its soft wrap text to true
end if
end tell
end tell
end tell
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
on cng(findText, changeText, srcData)
change findText into changeText in srcData with regexp without case sensitive
end cng
------------------------------------------------------------------------------------------------
on dateStr()
tell (current date)
set d to (its month as number) & (its day as number) & (its year) mod (((its year) div 1000) * 1000)
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
set d to d as text
set AppleScript's text item delimiters to oldTIDS
return d
end tell
end dateStr
------------------------------------------------------------------------------------------------
on winBounds(percentScreenWidth)
tell application "Finder" to set {x1, y1, x2, y2} to bounds of window of desktop
set winWidth to (percentScreenWidth * x2) div 1
set newX1 to (x2 - winWidth) div 2
set newX2 to newX1 + winWidth
set newBounds to {newX1, 44, newX2, y2}
return newBounds
end winBounds
------------------------------------------------------------------------------------------------
tell application "Safari"
if front document exists then
tell front document
set theURL to its URL
set pageText to its text
end tell
end if
end tell
------------------------------------------------------------------------------------------------
set pageHdr to dateStr() & return & return & theURL & return & return
set pageText to cng(linefeed, return, pageText)
set pageText to pageHdr & pageText
------------------------------------------------------------------------------------------------
tell application "BBEdit"
activate
set newDoc to make new document with properties {text:pageText}
set bounds of front window to winBounds(0.5) of me
tell newDoc
tell its text
straighten quotes with replacing target
select insertion point before character 1
end tell
tell its window
if soft wrap text = false then
set its soft wrap text to true
end if
end tell
end tell
end tell
------------------------------------------------------------------------------------------------