title: How to develop Chrome extension for Gmail?
body: <p>I'm thinking about developing Chrome extension for Gmail and I want to know what are the current best practices.</p>
  <p>For instance:</p>
  <ul>
  <li>attaching a GPG signature by default to every email</li>
  <li>adding an extra button that does something <em>(I have it already)</em></li>
  <li>hijacking action of sending email and prompting me to do complete something</li>
  <li>...</li>
  <li><em>(just them examples helping me to discover what is possible)</em></li>
  </ul>
  <p>There are quite a few notable extensions that significantly augment gmail functionality:</p>
  <ul>
  <li><a href="http://www.boomeranggmail.com/" rel="noreferrer">http://www.boomeranggmail.com/</a></li>
  <li><a href="http://toolbox.mxhero.com/" rel="noreferrer">http://toolbox.mxhero.com/</a></li>
  <li><a href="http://www.wisestamp.com/" rel="noreferrer">http://www.wisestamp.com/</a></li>
  <li>...</li>
  <li><em>(I'm not affiliated with any of them, I just named a few)</em></li>
  </ul>
  <p>One option would be to peek into their source which is located here
  <code>~/Library/Application Support/Google/Chrome/Default</code></p>
  <p>But maybe there is (wishful thinking) a good tutorial / set of practises on how to fiddle with gmail UI and functionality?</p>
  <p><a href="https://stackoverflow.com/questions/8689905/gmail-extension-gadget-api-how-to-add-a-button-to-the-compose-toolbar">Gmail extension/gadget API - how to add a button to the compose toolbar?</a></p>
  <blockquote>
  <p>You will have to create and inject the button programmatically. This will involve quite a bit of scouring the Gmail source code (spoiler: it's ugly).</p>
  </blockquote>
  <p><a href="https://stackoverflow.com/questions/10718913/how-to-build-a-chrome-extension-to-add-panel-to-gmail-windows?rq=1">How to build a chrome extension to add panel to gmail windows?</a></p>
  <blockquote>
  <p>The greatest long-term challenge you will face is that gmail's layout will change unexpectedly and break email discovery or the modified UI. Both issues either require some cleverness to solve, or will require you to stay up at night wondering whether Google will suddenly break your extension.</p>
  </blockquote>
  <p><a href="http://www.jamesyu.org/2011/02/05/introducing-gmailr-an-unofficial-javscript-api-for-gmail/" rel="noreferrer">http://www.jamesyu.org/2011/02/05/introducing-gmailr-an-unofficial-javscript-api-for-gmail/</a></p>
  <blockquote>
  <p>They're all building out complex APIs with similar functionality, that can all break independently if Gmail decides to significantly change their app structure (which they inevitably will).</p>
  <p>Gmail runs its code through the closure compiler, thereby obfuscating everything. On top of that, Gmail is probably one of the most sophisticated javascript apps out there.</p>
  </blockquote>
  <p>Library by the founder of Parse - <a href="https://github.com/jamesyu/gmailr" rel="noreferrer">https://github.com/jamesyu/gmailr</a> - but haven't updated in 1.5 years.</p>
  <hr />
  <p>I can show you what I got so far, and just so know I don't particularly like selectors like <strong><code>.oh.J-Z-I.J-J5-Ji.T-I-ax7</code></strong></p>
  <p>Note: <a href="http://anurag-maher.blogspot.co.uk/2012/12/developing-google-chrome-extension-for.html" rel="noreferrer">http://anurag-maher.blogspot.co.uk/2012/12/developing-google-chrome-extension-for.html</a> <em>(he also does it, he also uses such an obfuscated selectors)</em></p>
  <h3>manifest.json</h3>
  <pre><code>&quot;content_scripts&quot;: [
    {
      &quot;matches&quot;: [&quot;https://mail.google.com/*&quot;],
      &quot;css&quot;: [&quot;mystyles.css&quot;],
      &quot;js&quot;: [&quot;jquery-2.1.0.js&quot;, &quot;myscript.js&quot;]
    }
  ]
  </code></pre>
  <h3>myscript.js</h3>
  <pre><code>var icon = jQuery(&quot;.oh.J-Z-I.J-J5-Ji.T-I-ax7&quot;)
  var clone = icon.clone();
  clone.attr(&quot;data-tooltip&quot;, &quot;my tooltip&quot;);
  clone.on(&quot;click&quot;, function() {
      jQuery(&quot;.aDg&quot;).append(&quot;&lt;p class='popup'&gt;... sample content ...&lt;/p&gt;&quot;);
  });
  icon.before(clone);
  </code></pre>
  <p><em>(reusing existing UI elements so my functionality looks natively)</em></p>
  <hr />
  <p><a href="https://developers.google.com/gmail/gadgets_overview" rel="noreferrer">https://developers.google.com/gmail/gadgets_overview</a></p>
  <p>There are Sidebar Gadgets and Contextual Gadgets but they don not offer what I want to achieve.</p>
  <blockquote>
  <p>Gmail Labs is a testing ground for experimental features that aren't quite ready for primetime. They may change, break or disappear at any time.</p>
  </blockquote>
  <p><a href="https://groups.google.com/forum/#!forum/gmail-labs-suggest-a-labs-feature" rel="noreferrer">https://groups.google.com/forum/#!forum/gmail-labs-suggest-a-labs-feature</a>
  It seems like the ability to develop Gmail Labs is locked to Google employees.</p>
  <p><a href="https://developers.google.com/gmail/" rel="noreferrer">https://developers.google.com/gmail/</a></p>
  <blockquote>
  <p>Need help? Find us on Stack Overflow under the gmail tag.</p>
  </blockquote>
  <hr />
  <h2>So yes, I would really like to know if there are any tutorials / reference materials out there?</h2>
  <p><em>(I reviewed many of the 'Similar Questions' and I'm afraid that my options here are limited, but I would be extremely happy if I shrine your enlightenment upon me)</em></p>