You might be able to use this macro as a starting point:
It says "Safari" in the Title, but it covers both Safari and Chrome.
For more information, see the wiki Searching the Forum for Answers section.