How to create a custom action - Syntax and a tutorial

Get more actions or share your own!
Locked
User avatar
DaveG
Flagfox Developer
Posts: 723
Joined: Wed Oct 03, 2007 9:06 pm
Location: Philadelphia, USA

How to create a custom action - Syntax and a tutorial

Post by DaveG » Thu Feb 18, 2010 11:55 pm

Flagfox custom action syntax

Syntax available since Flagfox 3.3:
  • {domainName} = Domain (host) name of the current web server
  • {IPaddress} = IP address of the current web server
  • {countryName} = Localized name of the country the current web server is in
  • {countryCode} = Two character country code for the country the current web server is in
Syntax added in Flagfox 4.0:
  • {fullURL} = The full URL of the current web page
  • {baseDomainName} = The base domain name of the current web server (domain with subdomain dropped)
  • {locale} = Your current content locale preference (the locale you're requesting for web pages)
  • {baseLocale} = The base portion of your current content locale (i.e. "en" instead of "en-us")
  • copystring: = Prefix a template with this to create a copy to clipboard action
Syntax added in Flagfox 4.1:
  • {title} = The title of the current web page
  • {meta-____} = Any meta tag in the current page can be fetched by filling in the blank; examples: {meta-author}, {meta-keywords}, {meta-description}
  • {locale-page} = The locale declared by the current web page (also available: {baseLocale-page})
  • {locale-UI} = The locale currently used by the Flagfox UI; the locale country names are in (also available: {baseLocale-UI})
  • {locale-OS} = The locale reported by your operating system (also available: {baseLocale-OS})
  • {TLD} = The top-level-domain portion of the domain name (public suffix; e.g. www.bbc.co.uk -> co.uk)
  • javascript: = Prefix a template with this to create an advanced JavaScript action that runs in a sandbox (prior versions supported this partially)
Placeholders are case-insensitive and may be used multiple times in each template. The "javascript:" protocol and "copystring:" pseudo-protocol are case-sensitive. It's also possible to create advanced actions which use the "data:" protocol.

Flagfox 3.3 allowed only one custom action at a time. Flagfox 4+ greatly improved the system to allow any number of actions.

A quick tutorial in creating a custom action

Lets go through an example for anyone who needs a bit of help. This tuturial will assume you're using the latest version of Flagfox 4.0. (see above)

The example I will use is for Network-Tools.com whois search. Go to the page and try it out. If you paste a domain name like "addons.mozilla.org" into its search field with "Whois" selected you'll be taken to:

Code: Select all

http://network-tools.com/default.asp?prog=whois&host=addons.mozilla.org
This is the page they're giving you with the results of their lookup. Notice the end part of the URL? It's the domain name you searched for. What we're going to want to do for Flagfox is to take this URL and generalize it. Look at the table of placeholders in the add action dialog in Flagfox (also listed above). There's one labeled "Domain (host) name" called "{domainName}". We're making a custom action to look up a domain name with someone, so that's the one we want. Now, simply replace the part of the URL with the parameter you want Flagfox to use when doing its lookup. The result is:

Code: Select all

http://network-tools.com/default.asp?prog=whois&host={domainName}
Now, create a new action in Flagfox's options and use that as the template. Name it something useful like "Network-Tools" or "N-T Whois" or just "Whois" if you're feeling lazy. Duplicate names are perfectly fine. If you want to set it to a shortcut you can do so here or just leave those two blank. You can come back and edit this all later if you need to.

After you save, go to some page, for example http://www.google.com. Right-click on the Flagfox icon and click your new lookup. Flagfox will now load up the lookup for that page. For this example, it'll be:

Code: Select all

http://network-tools.com/default.asp?prog=whois&host=www.google.com
Make sure it's working and give it another shot on a few other sites if you like. Congrats, you've created a new custom Flagfox action. :)

The procedure is the same for other lookups using different information. To continue the example, you could go back to the Network-Tools.com page and select to do a spam blacklist check with an IP address rather than a domain name. Paste in an IP address (which you can get easily with Flagfox's "Copy IP" action) and the results page will have a slightly different URL, this time for the different check and with an IP address in it. Replace the IP address in the results URL with the aptly named "{IPaddress}" placeholder and then create a new Flagfox action as before with this template URL. Voila, another custom action created.

Any site which has a service that uses some form of URL pattern like this can be turned into a custom lookup for Flagfox like this.

If you'd like to see what the default actions' template URLs look like, you can do so here.
Last edited by DaveG on Fri Mar 04, 2011 6:31 am, edited 2 times in total.
Reason: updated for Flagfox 4.1

Locked