Difference between revisions of "Development:Camino AppleScript Guide"

From Camino Wiki
Jump to navigation Jump to search
(we support referrers!)
(→‎New in Camino 2.1.1: add online property)
Line 8: Line 8:
 
* Send a referrer when opening URLs
 
* Send a referrer when opening URLs
 
** The <code>open location</code> command now has an optional <code>using referrer</code> parameter.  If the URL to be opened is already displayed in a tab or window and a referrer is specified, Camino will not reload the existing tab but will instead open a new tab or window to load the requested URL using the supplied referrer.
 
** The <code>open location</code> command now has an optional <code>using referrer</code> parameter.  If the URL to be opened is already displayed in a tab or window and a referrer is specified, Camino will not reload the existing tab but will instead open a new tab or window to load the requested URL using the supplied referrer.
 +
* Online state (“offline mode”) is now scriptable
 +
** Camino’s <code>application</code> object now has an <code>online</code> property, which can be queried to determine if Camino is online or is operating in “offline mode”.  Scripts can also take Camino online and offline by setting the value of the <code>online</code> property.  (Note: No amount of setting <code>online</code> to <code>true</code> will allow Camino to load pages if there is no network connection!)
  
 
==New in Camino 2.1==
 
==New in Camino 2.1==

Revision as of 15:46, 30 January 2012

DRAFT
This page is not complete.

The following page is a guide to the AppleScript features available in Camino 1.6, Camino 2.0, and Camino 2.1.

Camino 1.6 introduced significant improvements in AppleScript support over previous versions of Camino. Some of these improvements required incompatible changes to commands and properties. Many scripts will continue to work correctly in Camino 1.6 and later; however, scripts that use certain commands and properties, and text scripts (.applescript), will need changes in order to continue functioning.

New in Camino 2.1.1

  • Send a referrer when opening URLs
    • The open location command now has an optional using referrer parameter. If the URL to be opened is already displayed in a tab or window and a referrer is specified, Camino will not reload the existing tab but will instead open a new tab or window to load the requested URL using the supplied referrer.
  • Online state (“offline mode”) is now scriptable
    • Camino’s application object now has an online property, which can be queried to determine if Camino is online or is operating in “offline mode”. Scripts can also take Camino online and offline by setting the value of the online property. (Note: No amount of setting online to true will allow Camino to load pages if there is no network connection!)

New in Camino 2.1

  • Tabs
    • The non-standard title property has been deprecated and is no longer visible in the dictionary. Scripts should switch to the standard name property (which works consistently for application, window, browser window, and tab). The name property is backwards-compatible with Camino 2.0, so scripts targeting both Camino 2.1 and 2.0 can still safely migrate from the deprecated title property.

New in Camino 2.0

  • Web page source and text
    • It is now possible to fetch the HTML source and displayed text of a browser window or tab using the source and text commands.
    • If a web page has a selection, it is also possible to return the HTML source and displayed text of just the selection using the selected source and selected text commands.
  • Tabs
    • It is now possible to set the current tab property of each browser window in order to change the active tab in that browser window.
    • Tabs now support name as an alias for the title property. It is our intention to deprecate the non-standard title property in a future release.

New in Camino 1.6

  • Browser Windows and Tabs
    • Browser windows can now be referenced specifically. Previously, Camino only exposed windows in general, including the Preferences window and the Downloads window in the same collection as browser windows.
    • Browser windows contain tabs.
    • Tabs can be addressed individually, exposing the title and URL of each page the user has open.
  • Bookmarks
    • Bookmarks and bookmark folders can be read, added, and modified by AppleScripts. (But see the important note below.)
  • WWW!OURL AppleEvent is deprecated
    • The old Spyglass WWW!OURL AppleEvent and its corresponding open url command have been deprecated. Scripts using these will not work in Camino 1.6, though they will work again in Camino 1.6.1. See below for a migration path.
    (Beginning with Dreamweaver CS5, Adobe no longer uses the deprecated WWW!OURL AppleEvent; see Bug 549680 Comment 10. Other applications should also cease using WWW!OURL and switch to the standard GURLGURL AppleEvent.)

Implementing Toolbar Script Items

Anomalies in the Camino AppleScript Dictionary

  • Making new tabs or browser windows
    Although the make command is present, it is currently not possible to make new tab or make new browser window. For technical information about the reasons for this, see this blog post.
     
    If a user has “Links opened by other applications” checked (in the Tabs preference pane), it is possible to use open location "about:blank" to fake opening a new tab and then use set URL of current tab of front browser window to load the desired URL.
  • Certain items present in the Standard Suite will compile but are not implemented in Camino at this time (Bug 394581).
  • browser window 0 and tab 0 resolve to a browser window/tab (browser window/tab 1) but should not (Bug 395716).
  • If the user has enabled the “closing windows or quitting with multiple pages open” warnings, these alerts will also fire when AppleScripts attempt to perform these actions. There is currently no way for the script to disable these alerts on a case-by-case basis (Bug 391684).
  • “Phantom” windows caused by tooltips (one phantom window per tab, so long as the tab is open) can show up in the count of windows (Bug 437802).
  • Using UI Scripting to access Camino’s UI can cause toolbar scripts to take forever, time out, or hang Camino. If you need to use UI Scripting to access Camino UI, run your script from the Script menu instead of as a toolbar script (Bug 448992).
  • It currently is not possible to reload the current tab in Camino (Bug 557057), but the following script will provide equivalent functionality:
    tell application "Camino"
        set theURL to URL of current tab of browser window 1
        open location theURL
    end tell

Migrating Scripts from Camino 1.5 to Camino 1.6

  • The Get URL command has been replaced by open location. Compiled scripts should handle this change automatically in most cases.
  • The open url command (and its corresponding «event WWW!OURL») has been deprecated. Scripts should use open location instead. Any compiled scripts using this event will re-resolve to DeprecatedOpenURL terminology when opened in ScriptEditor with Camino 1.6.1 and later, and those instances should be changed manually to use open location to ensure compatibility with future versions of Camino. (Scripts using open url or «event WWW!OURL» will fail in Camino 1.6 but will work again in Camino 1.6.1.)
  • The window class now properly refers to all open windows (including the Downloads and Preferences windows). To target a browser window, use browser window instead.