Use Script Editor to develop bookmarklets

May 08, '08 07:30:00AM

Contributed by: channui

If you're developing a non-trivial bookmarklet you may be able to speed up your edit cycle by having an applescript which executes the javascript in your browser, like this:

tell application "Safari"
  activate
  do JavaScript "
    // Of course your bookmarklet code goes here, for example...
    alert('hello world');
  " in front document
end tell
I just edited the Javascript in Script Editor and hit the run button to test. Just be careful of using double quotes, and you can postpone escaping the script and adding it to your bookmarks until the very end.

Comments (1)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20080506093246423