- commit
- 4960e93ac0b3613c574887913ef2d69c3400ec2b
- parent
- f96a6382bb71092ab2bbbd1909d313d28b5a419a
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2022-09-28 06:12
get viewSource functionality closer to builtin
Diffstat
| D | content/source.html | 11 | ----------- |
| D | content/source.js | 6 | ------ |
| M | experiment-api/api.js | 11 | +++++++++++ |
| M | experiment-api/schema.json | 8 | ++++++++ |
| M | src/js/actions.js | 2 | +- |
5 files changed, 20 insertions, 18 deletions
diff --git a/content/source.html b/content/source.html
@@ -1,11 +0,0 @@1 -1 <!DOCTYPE html>2 -1 <html>3 -1 <head>4 -1 <meta charset="UTF-8">5 -1 <title>View source</title>6 -1 </head>7 -1 <body>8 -1 <pre class="source"></pre>9 -1 <script src="source.js"></script>10 -1 </body>11 -1 </html>
diff --git a/content/source.js b/content/source.js
@@ -1,6 +0,0 @@1 -1 var pre = document.querySelector('.source');2 -1 var id = parseInt(location.search.substr(4), 10);3 -14 -1 browser.messages.getRaw(id).then(source => {5 -1 pre.textContent = source;6 -1 });
diff --git a/experiment-api/api.js b/experiment-api/api.js
@@ -103,6 +103,17 @@ var xi = class extends ExtensionCommon.ExtensionAPI {
103 103 var attInfo = new win.AttachmentInfo(null, url, params.filename, msg2uri(msgHdr));
104 104 attInfo.save();
105 105 },
-1 106 viewSource(id) {
-1 107 var win = Services.wm.getMostRecentWindow('mail:3pane');
-1 108 var msgHdr = context.extension.messageManager.get(id);
-1 109 var url = msgHdr.folder.folderURL + '?number=' + msgHdr.messageKey;
-1 110 win.openDialog(
-1 111 'chrome://messenger/content/viewSource.xhtml',
-1 112 '_blank',
-1 113 'all,dialog=no',
-1 114 {URL: url},
-1 115 );
-1 116 },
106 117 createTab(url) {
107 118 let win = Services.wm.getMostRecentWindow("mail:3pane");
108 119 let nativeTabInfo = win.openTab("contentTab", {
diff --git a/experiment-api/schema.json b/experiment-api/schema.json
@@ -42,6 +42,14 @@ 42 42 "type": "string" 43 43 }] 44 44 }, { -1 45 "name": "viewSource", -1 46 "type": "function", -1 47 "async": false, -1 48 "parameters": [{ -1 49 "name": "id", -1 50 "type": "integer" -1 51 }] -1 52 }, { 45 53 "name": "createTab", 46 54 "type": "function", 47 55 "async": false,
diff --git a/src/js/actions.js b/src/js/actions.js
@@ -1,7 +1,7 @@ 1 1 /* global browser */ 2 2 3 3 var viewSource = function(msg) {4 -1 browser.tabs.create({url: '/content/source.html?id=' + msg.id});-1 4 browser.xi.viewSource(msg.id); 5 5 }; 6 6 7 7 var markAsRead = function(msg, read) {