Hello
This reveals thelocal html file currently rendered in your browser, this script goes into the WebpageHelper.app, see MacScripter / Script that automates the conversion from markdown to html and MacScripter / Locate and edit markdown counterpart of html file displayed in Safari for details.
-- © McUsr 2012 and put in Public Domain. You may not post,and not store this in a public accessible repository
-- but refer to the link here: http://macscripter.net/viewtopic.php?pid=154994#p154994
property warnIcon : a reference to file ((path to library folder from system domain as text) & "CoreServices:CoreTypes.bundle:Contents:Resources:AlertCautionIcon.icns")
property main_property : {}
on run
local myUnescapedUrl
try
if main_property starts with "file" then
set myUnescapedUrl to my decodefurl(main_property)
do shell script "open -R " & quoted form of myUnescapedUrl
return true
else
tell application "SystemUIServer"
activate
display dialog "This script works with files rendered in the browser" with title "Webpage Helper" buttons {"Ok"} default button 1 with icon warnIcon
return false
end tell
end if
on error e number n
logMessage2("WebPageHelper", "Reveal current file from browser-- Error: " & e & " " & n)
tell application "SystemUIServer"
activate
display dialog e with title "Webpage Helper" buttons {"Ok"} default button 1 with icon warnIcon
end tell
return false
end try
end run
on logMessage2(procName, Msg)
-- needs a decl like this in the run handler (implicit or explicit )
do shell script "/usr/bin/logger -s -t " & quoted form of procName & " " & quoted form of Msg
end logMessage2
on isAvalidHtmlFileUrl(theUrl)
local ok, astid
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
if not text item 1 of theUrl is "file" then
set AppleScript's text item delimiters to astid
return false
end if
set AppleScript's text item delimiters to "."
if not text item -1 of theUrl is "html" then
set AppleScript's text item delimiters to astid
return false
end if
set AppleScript's text item delimiters to astid
return true
end isAvalidHtmlFileUrl
on decodefurl(anUrlFromABrowser)
-- 27/08/12 Tested!
-- konverterer escaped chars tilbake til normal
-- fjerner file, og local host.
-- localhost starter helt til å begynne med i tilfelle.
local tmpUrl
set tmpUrl to my rawURLDecode(anUrlFromABrowser)
set tmpUrl to my str_replace({substringToReplace:"file://", replacementString:"", OriginalString:tmpUrl})
if (offset of "localhost" in tmpUrl) is 1 then set tmpUrl to text 10 thru -1 of tmpUrl
return tmpUrl
end decodefurl
-- DJ Bazzie Wazzie http://macscripter.net/edit.php?id=154949
on rawURLDecode(str)
return do shell script "/bin/echo -n " & quoted form of str & " | php -r ' echo rawurldecode(fgets(STDIN)); '"
end rawURLDecode
on str_replace(R) -- Returns modified string
-- R {substringToReplace: _ent, replacementString: _rent,OriginalString: _str}
local _tids
set _tids to AppleScript's text item delimiters
set AppleScript's text item delimiters to R's substringToReplace
set _res to text items of R's OriginalString as list
set AppleScript's text item delimiters to R's replacementString
set _res to items of _res as string
set AppleScript's text item delimiters to _tids
return _res
end str_replace