Note that there are some explanatory texts on larger screens.

plurals
  1. POGMail: Add a link next to each attachment download link
    primarykey
    data
    text
    <p>I'm working on a chrome extensions whose purpose is to add a "export to gdocs" link to each attachment in gmail.</p> <p>I've already implemented part of the code which successfully adds the link next to the "download" link, but I'm facing with a problem I don't know how to solve.</p> <p>The problem is: <strong>in a mail thread (with several replies), collapsed mails aren't affected by my script - and when they are expanded, the link is (as expected) not added</strong>.</p> <p>The reason why that occurs is that collapsed mails are loaded at runtime when expanded - so when my script is executed on page load there's no link to add as the mail content hasn't been loaded yet.</p> <p>I tried adding an update handler using the prototype framework and the sample code I found here:</p> <p><a href="http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/5ad539212ea07716?pli=1" rel="nofollow">http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/5ad539212ea07716?pli=1</a> (last post)</p> <p><a href="http://jsbin.com/utuvu" rel="nofollow">http://jsbin.com/utuvu</a></p> <p>but it doesn't work - although the solution itself is valid and working out of gmail.</p> <p>The partially working solution is implemented using a chrome.tabs onUpdate listener (registered in the background file), and some jquery (injected as content script) which:</p> <p>selects tables having the "cr hf" css classes (which are the ones used to contain the attachment links)</p> <pre><code>$('table.cf.hr').each(function() { injectLink($(this)); }); </code></pre> <p>for each one, looks up the download link, extracts some parameters from the download url, create a new link and adds next to the last link</p> <pre><code>function injectLink(table) { var downloadLink = table.find("td:last a:last"); var exportToGdocsLink = downloadLink.clone().attr(...)... ... downloadLink.after(exportToGdocsLink).after("&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;"); } </code></pre> <p>Has anybody implemented chrome extensions interacting with gmail? Any hint for me to figure out how to proceed?</p> <p><strong>UPDATE</strong></p> <p>The latest version of the code is this: </p> <pre><code>$('#canvas_frame').ready(function() { var doc = frames['canvas_frame'].contentDocument; $(doc).find('table.cf.hr').livequery(function() { injectLink($(this)); }); }); </code></pre> <p>but I've tried several "combinations" - this is the "closest to what expected" result. The <code>canvas_frame</code> is the iframe containing the entire gmail interface. The table having css classes <code>cr hf</code> contains the attachment links.</p> <p>Thanks Antonio</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload