WebKit in AppleScript - Bridging and source.. all very weird

If anyone can help with this I’ll be VERY happy, as the application I’m writing has been pretty annoying so far. I don’t know any C at all, and the program I’m making has to use webkit.

Here’s what I’m looking for: A WebView in my application (not the main purpose,) the main idea is that normally the app will retrieve the source of a page, but if need be can also function as a VERY simple web browser. The source needs to be retrieved through webkit, not curl or something because the particular page requires a Microsoft Passport to log in, and a WebKit app will remember the login information and cookies from safari.

So in a nutshell, HTML source through webkit.

I really need this, and if anyone can help, I’ll put their names in the about box and maybe some sort of better compensation if I can think of a way.

Additionaly, if anyone knows how to dynamically create a menu divider, or make a floating transparent bezel window, or put a search field in a menu extra, that information would be much appreciated too.

In closing, thanks for actually reading this, and perhaps helping.


You can use curl to send cookies, so these are read in the remote url (and also retrieve new ones sent by the called page using the “-c” flag). Eg:

--> login url
set URLApp to quoted form of "http://site.com/login.php"
--> cookies stored currently in Safari
set theCookies to quoted form of "user_name=joe;user_pwd=2adf42e13120"
--> referrer
set referrer to quoted form of "http://site.com/login.php"
--> url-encoded-form-data, as if you fill a form
set URLEncodedFormData to "showcomments=1"

do shell script "curl -A 'Mozilla/4.0' -e " & referrer & " -b " & theCookies & " -d " & URLEncodedFormData & space & URLApp & " -c /tmp/cookies.txt -o /tmp/submit.html"

if (read ("/tmp/submit.html" as POSIX file)) contains "Login OK" then
	display dialog "Login OK"
	display dialog "Unable to login"
end if