{"id":351,"date":"2009-07-23T05:34:12","date_gmt":"2009-07-23T13:34:12","guid":{"rendered":"http:\/\/www.visophyte.org\/blog\/?p=351"},"modified":"2009-07-23T05:34:12","modified_gmt":"2009-07-23T13:34:12","slug":"thunderbird-jetpack-messagedisplay-overridemessagedisplay-fun","status":"publish","type":"post","link":"https:\/\/www.visophyte.org\/blog\/2009\/07\/23\/thunderbird-jetpack-messagedisplay-overridemessagedisplay-fun\/","title":{"rendered":"Thunderbird Jetpack messageDisplay.overrideMessageDisplay fun."},"content":{"rendered":"<p><a href=\"http:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/07\/jetpack-twitter-follow-notification.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-352\" title=\"jetpack-twitter-follow-notification\" src=\"http:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/07\/jetpack-twitter-follow-notification-600x584.png\" alt=\"jetpack-twitter-follow-notification\" width=\"600\" height=\"584\" srcset=\"https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/07\/jetpack-twitter-follow-notification-600x584.png 600w, https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/07\/jetpack-twitter-follow-notification-300x292.png 300w, https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/07\/jetpack-twitter-follow-notification.png 861w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>As part of our goal to make it easy to write extensions for Thunderbird 3, we&#8217;ve been working on getting Jetpack running under Thunderbird and exposing Thunderbird-specific points.  This is all experimental, but it&#8217;s having good results.<\/p>\n<p>The <a href=\"http:\/\/hg.mozilla.org\/users\/bugmail_asutherland.org\/jetpack-tb-examples\/file\/a117452f167b\/message-display\/sender-specific\/twitter-followed.js\">first example<\/a> replaces the message you get from twitter when someone follows you and instead shows you that person&#8217;s twitter page so you can see what they&#8217;ve written.  Unfortunately, if you try and click on links on the page you will become sad because they all try and trigger your web browser.  But <a href=\"http:\/\/ccgi.standard8.plus.com\/blog\">Standard8<\/a> is hard at work resolving the content display issues.  Besides demonstrating registration via a regex over the sender&#8217;s e-mail address, it also shows us extracting message headers from the message.  Also, we introduce a small HTML snippet that precedes the nested web browser so it&#8217;s not just an embedded web browser.<\/p>\n<pre lang=\"javascript\" escaped=\"true\">jetpack.future.import(\"thunderbird.messageDisplay\");\r\njetpack.thunderbird.messageDisplay.overrideMessageDisplay({\r\n  match: {\r\n    fromAddress: \/twitter-follow-[^@]+@postmaster.twitter.com\/\r\n  },\r\n  onDisplay: function(aGlodaMsg, aMimeMsg) {\r\n    let desc = aMimeMsg.get(\"X-Twittersendername\", \"some anonymous jerk\") +\r\n      \" has followed you on Twitter.  Check out their twitter page below.\";\r\n    return {\r\n      beforeHtml:\r\n        &lt;&gt;\r\n          &lt;div style=\"background-color: black; color: white; padding: 3px; margin: 3px; -moz-border-radius: 3px;\"&gt;\r\n            {desc}\r\n          &lt;\/div&gt;\r\n        &lt;\/&gt;\r\n      url: \"http:\/\/twitter.com\/\" + aMimeMsg.get(\"X-Twittersenderscreenname\")\r\n    };\r\n  }\r\n});<\/pre>\n<p><a href=\"http:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/07\/jetpack-amazon-big-total.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-356\" title=\"jetpack-amazon-big-total\" src=\"http:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/07\/jetpack-amazon-big-total-600x404.png\" alt=\"jetpack-amazon-big-total\" width=\"600\" height=\"404\" srcset=\"https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/07\/jetpack-amazon-big-total-600x404.png 600w, https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/07\/jetpack-amazon-big-total-300x202.png 300w, https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/07\/jetpack-amazon-big-total.png 664w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Our <a href=\"http:\/\/hg.mozilla.org\/users\/bugmail_asutherland.org\/jetpack-tb-examples\/file\/a117452f167b\/message-display\/sender-specific\/amazon-big-total.js\">second example<\/a> of the extension point replaces e-mails from Amazon about an order (order confirmation and shipment confirmation) with the amount of money you spent on the order in BIG LETTERS (or rather BIG NUMBERS).  It uses a regular expression run against the message body to find the total order cost.  Then it generates a simple web page to present the information to you.<\/p>\n<pre lang=\"javascript\" escaped=\"true\">jetpack.future.import(\"thunderbird.messageDisplay\");\r\njetpack.thunderbird.messageDisplay.overrideMessageDisplay({\r\n  match: {\r\n    fromAddress: \/(?:auto-confirm|ship-confirm)@amazon.(?:com|ca)\/\r\n  },\r\n  _totalRe: \/Total(?: for this Order)?:[^$]+\\$\\s*(\\d+\\.\\d{2})\/,\r\n  onDisplay: function(aGlodaMsg, aMimeMsg, aMsgHdr) {\r\n    let bodyText = aMimeMsg.coerceBodyToPlaintext(aMsgHdr.folder);\r\n    let match = this._totalRe.exec(bodyText);\r\n    let total = match ? match[1] : \"hard to say\";\r\n    return {\r\n      html:\r\n      &lt;&gt;\r\n        &lt;style&gt;&lt;![CDATA[\r\n          body { background-color: #ffffff; }\r\n          .amount { font-size: 800%; }\r\n        ]]&gt;&lt;\/style&gt;\r\n        &lt;body&gt;\r\n          you spent... &lt;span class=\"amount\"&gt;${total}&lt;\/span&gt;\r\n        &lt;\/body&gt;\r\n      &lt;\/&gt;\r\n    };\r\n  }\r\n});<\/pre>\n<p>The modified version of Jetpack can be found <a href=\"http:\/\/hg.mozilla.org\/users\/bugmail_asutherland.org\/opc-jetpack\/\">here<\/a> on the &#8220;thunderbird&#8221; branch.  &#8220;about:jetpack&#8221; can be triggered from the &#8220;Tools&#8221; menu.  Besides the development jetpack, you can also add jetpacks from the about:jetpack &#8220;Installed Features&#8221; tab by providing a URL directly to the javascript file.  Unfortunately, I just tried installed more than one Feature at the same time and that fell down.  I&#8217;m unclear if that&#8217;s a Thunderbird content issue, a problem with my changes, or a problem in Jetpack\/Ubiquity that may go away when I update the branch.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As part of our goal to make it easy to write extensions for Thunderbird 3, we&#8217;ve been working on getting Jetpack running under Thunderbird and exposing Thunderbird-specific points. This is all experimental, but it&#8217;s having good results. The first example &hellip; <a href=\"https:\/\/www.visophyte.org\/blog\/2009\/07\/23\/thunderbird-jetpack-messagedisplay-overridemessagedisplay-fun\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[6],"tags":[68,67],"class_list":["post-351","post","type-post","status-publish","format-standard","hentry","category-thunderbird","tag-extensions","tag-jetpack"],"_links":{"self":[{"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/posts\/351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/comments?post=351"}],"version-history":[{"count":9,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/posts\/351\/revisions"}],"predecessor-version":[{"id":362,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/posts\/351\/revisions\/362"}],"wp:attachment":[{"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/media?parent=351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/categories?post=351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/tags?post=351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}