(Now sending from the right account, so this email will appear out of order within the thread for most of you and duplicate to some) :)
Anand, Take a look at the source for the Email This Page extension in the samples. The background page does exactly what Erik is describing... http://code.google.com/chrome/extensions/samples.html -Finnur On Tue, Dec 8, 2009 at 13:34, Anand Rangarajan <a...@google.com> wrote: > oh! sorry.. that cut and paste was from old code. > yes, the executeScript is not supposed to be commented out. > But, the thing works sometimes and does not some other times. > I wonder if there is a "timing" issue here. > > On Tue, Dec 8, 2009 at 12:11 PM, Erik Kay <erik...@google.com> wrote: > >> Hi Anand, >> >> From the code, it looks to me like the selected text should never work. >> Your summaryText() is called immediately at page load time and never called >> again. This will always be be empty, right? You have some commented out >> code to send it on mouseup. Did you intend to leave that commented out? >> >> It also looks like you have some commented out code using executeScript on >> demand rather than injecting script into all pages all of the time. I'd >> highly recommend you use this approach as it will be much more efficient. >> >> Erik >> >> >> On Tue, Dec 8, 2009 at 11:05 AM, Anand Rangarajan <a...@google.com> wrote: >> >>> >>> https://chrome.google.com/extensions/detail/pgphcomnlaojlmmcjmiddhdapjpbgeoc >>> >>> Hi Chrome Extension experts, >>> >>> I wrote this extension, and it works well for me. I am on Chrome >>> 4.0.249.25 >>> But, some people claim the selected text does not appear for them. >>> Can you help me by saying why the content script may not send the >>> selected text >>> to the background page sometimes? >>> >>> The Published code may not be accessible, so I am giving the pertinent >>> details inline here: >>> >>> == infopasser.js >>> summaryText(); >>> // window.addEventListener("mouseup", summaryText); >>> >>> function summaryText() { >>> console.log("Being Called"); >>> chrome.extension.sendRequest( >>> window.getSelection().toString() >>> ); >>> } >>> >>> == background.html >>> var subjectPrefix = ''; >>> var title = ''; >>> var url = ''; >>> var summ = ''; >>> chrome.extension.onRequest.addListener( >>> function(conn) { >>> summ = conn; >>> }); >>> >>> // From = <whatever gmail account is logged in; If not logged in, >>> redirects to login page> >>> // To = <Unfilled> >>> // [TODO: In the next version, may provide some Options for >>> favorite recipients] >>> // Subject = [Interesting Page] <Page's Title> >>> // Body = Summary Selection + URL >>> chrome.browserAction.onClicked.addListener( >>> function(tab) { >>> // chrome.tabs.executeScript(null, {file: "infopasser.js"}); >>> title = tab.title; >>> url = tab.url; >>> makeGmailWin(summ); >>> }); >>> == >>> >>> Some people say they do not get the selected text. I doubt this is an >>> issue with the Chrome >>> version. >>> >>> thanks much, >>> anand >>> >>> -- >>> >>> You received this message because you are subscribed to the Google Groups >>> "Chromium-extensions" group. >>> To post to this group, send email to >>> chromium-extensi...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> chromium-extensions+unsubscr...@googlegroups.com<chromium-extensions%2bunsubscr...@googlegroups.com> >>> . >>> For more options, visit this group at >>> http://groups.google.com/group/chromium-extensions?hl=en. >>> >>> >>> >> > -- > You received this message because you are subscribed to the Google Groups > "Chromium-extensions" group. > To post to this group, send email to chromium-extensi...@googlegroups.com. > To unsubscribe from this group, send email to > chromium-extensions+unsubscr...@googlegroups.com<chromium-extensions%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/chromium-extensions?hl=en. > -- You received this message because you are subscribed to the Google Groups "Chromium-extensions" group. To post to this group, send email to chromium-extensi...@googlegroups.com. To unsubscribe from this group, send email to chromium-extensions+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/chromium-extensions?hl=en.