Skip to content
This repository has been archived by the owner on Jan 4, 2025. It is now read-only.

Commit

Permalink
! Compatibility with Thunderbird 60.*
Browse files Browse the repository at this point in the history
  • Loading branch information
geekley committed May 18, 2019
1 parent 4fa1804 commit 9f41930
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 36 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
This is a fork of the original extension from Mossop that just fixes the icon problem.
It gets the icon URLs from google automatically, but also allows the user to set a custom URL.
This is a fork of the original extension that fixes some problems.
It gets the favicon URLs from google automatically, but also allows the user to set a custom URL.
The XPI that can be installed into Thunderbird is in the releases tab.
Updated to be compatible with Thunderbird 60.*.

**Known Bugs:**
- Sometimes tabs won't close while the extension is enabled.
- Sometimes tabs are "locked" on the page, and you can't go to a different URL.

The original project is not mantained anymore. Part of the original README follows below.

Expand Down Expand Up @@ -37,4 +42,4 @@ The main goals are:
License
------------

As always feel free to fork. This project is MPL/GPL/LGPL tri-licensed.
As always feel free to fork. This project is licensed under MPL-2.0.
6 changes: 3 additions & 3 deletions src/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ function install(aParams, aReason) {

function startup(aParams, aReason) {
// Register the resource://webapptabs/ mapping
Components.utils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
let res = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandler);
res.setSubstitution("webapptabs", aParams.resourceURI);

// Add our chrome registration
Components.manager.addBootstrappedManifestLocation(aParams.installPath);

// Load the overlay manager
Components.utils.import("resource://webapptabs/modules/OverlayManager.jsm");
ChromeUtils.import("resource://webapptabs/modules/OverlayManager.jsm");

// Add a policy to handle redirecting webapp loads
OverlayManager.addComponent("{bd71af62-1b21-4f3a-829e-5254ec7da7f6}",
Expand All @@ -104,7 +104,7 @@ function startup(aParams, aReason) {

OverlayManager.addOverlays(OVERLAYS);

Components.utils.import("resource://webapptabs/modules/ConfigManager.jsm");
ChromeUtils.import("resource://webapptabs/modules/ConfigManager.jsm");
Services.obs.addObserver(HttpObserver, "http-on-modify-request", false);
}

Expand Down
10 changes: 5 additions & 5 deletions src/components/nsContentPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://webapptabs/modules/LogManager.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://webapptabs/modules/LogManager.jsm");
LogManager.createLogger(this, "nsContentPolicy");
Components.utils.import("resource://webapptabs/modules/ConfigManager.jsm");
Components.utils.import("resource://webapptabs/modules/OverlayManager.jsm");
ChromeUtils.import("resource://webapptabs/modules/ConfigManager.jsm");
ChromeUtils.import("resource://webapptabs/modules/OverlayManager.jsm");

const Cc = Components.classes;
const Ci = Components.interfaces;
Expand Down Expand Up @@ -78,7 +78,7 @@ nsContentPolicy.prototype = {
// Otherwise load it externally
Cc["@mozilla.org/uriloader/external-protocol-service;1"].
getService(Components.interfaces.nsIExternalProtocolService).
loadUrl(aContentLocation);
loadURI(aContentLocation);

logResult("REJECT", "Loaded externally");
return Ci.nsIContentPolicy.REJECT_SERVER;
Expand Down
4 changes: 2 additions & 2 deletions src/content/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

Components.utils.import("resource://webapptabs/modules/LogManager.jsm");
ChromeUtils.import("resource://webapptabs/modules/LogManager.jsm");
LogManager.createLogger(this, "config");
Components.utils.import("resource://webapptabs/modules/ConfigManager.jsm");
ChromeUtils.import("resource://webapptabs/modules/ConfigManager.jsm");

const Cc = Components.classes;
const Ci = Components.interfaces;
Expand Down
8 changes: 4 additions & 4 deletions src/content/webtab.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/NetUtil.jsm");
Components.utils.import("resource://webapptabs/modules/LogManager.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
ChromeUtils.import("resource://webapptabs/modules/LogManager.jsm");
LogManager.createLogger(this, "webtab");
Components.utils.import("resource://webapptabs/modules/ConfigManager.jsm");
ChromeUtils.import("resource://webapptabs/modules/ConfigManager.jsm");

var Cc = Components.classes;
var Ci = Components.interfaces;
Expand Down
8 changes: 4 additions & 4 deletions src/install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
<em:optionsURL>chrome://webapptabs/content/config.xul</em:optionsURL>

<em:name>WebApp Tabs</em:name>
<em:version>2.1.1-icon-fixed</em:version>
<em:version>4.0.60</em:version>
<em:creator>Dave Townsend</em:creator>
<em:contributor>David Ascher (original code), geekley (icon fix)</em:contributor>
<em:contributor>David Ascher (original code), geekley (fixes, compatibility)</em:contributor>
<em:description>Load WebApps into tabs in Thunderbird</em:description>
<em:homepageURL>http://www.fractalbrew.com/webapp-tabs/</em:homepageURL>

<!-- Thunderbird -->
<em:targetApplication>
<Description>
<em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
<em:minVersion>8.0</em:minVersion>
<em:maxVersion>52.7.0</em:maxVersion>
<em:minVersion>59.0</em:minVersion>
<em:maxVersion>60.*</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
Expand Down
6 changes: 3 additions & 3 deletions src/modules/ConfigManager.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

const EXPORTED_SYMBOLS = ["ConfigManager"];

Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/NetUtil.jsm");
Components.utils.import("resource://webapptabs/modules/LogManager.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/NetUtil.jsm");
ChromeUtils.import("resource://webapptabs/modules/LogManager.jsm");
LogManager.createLogger(this, "ConfigManager");

const Cc = Components.classes;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/LogManager.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

const EXPORTED_SYMBOLS = ["LogManager"];

Components.utils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/Services.jsm");

const Cc = Components.classes;
const Ci = Components.interfaces;
Expand Down
23 changes: 12 additions & 11 deletions src/modules/OverlayManager.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

const EXPORTED_SYMBOLS = ["OverlayManager"];

Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://webapptabs/modules/LogManager.jsm");
Components.utils.importGlobalProperties(["XMLHttpRequest"]);
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://webapptabs/modules/LogManager.jsm");
LogManager.createLogger(this, "OverlayManager");

const Cc = Components.classes;
Expand Down Expand Up @@ -138,7 +139,8 @@ const OverlayManagerInternal = {

this.windowEntryMap.delete(aWindowEntry.window);

for (let [,sandbox] in Iterator(aWindowEntry.scripts)) {
for (let scriptURL in aWindowEntry.scripts) {
let sandbox = aWindowEntry.scripts[scriptURL];
try {
if ("OverlayListener" in sandbox && "unload" in sandbox.OverlayListener)
sandbox.OverlayListener.unload();
Expand Down Expand Up @@ -189,8 +191,7 @@ const OverlayManagerInternal = {
LOG("Loading document overlay " + aDocumentURL);

// TODO make this async
let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
createInstance(Ci.nsIXMLHttpRequest);
let xhr = new XMLHttpRequest();
xhr.open("GET", aDocumentURL, false);
xhr.send();

Expand All @@ -200,7 +201,7 @@ const OverlayManagerInternal = {

let targetDoc = aWindowEntry.window.document;

function walkDocumentNodes(aDocument) {
function* walkDocumentNodes(aDocument) {
let node = aDocument.documentElement;

while (node) {
Expand All @@ -224,7 +225,7 @@ const OverlayManagerInternal = {
}
}

function elementChildren(aElement) {
function* elementChildren(aElement) {
let node = aElement.firstChild;
while (node) {
let currentNode = node;
Expand All @@ -236,13 +237,13 @@ const OverlayManagerInternal = {
}
}

for (let node in walkDocumentNodes(overlayDoc)) {
for (let node of walkDocumentNodes(overlayDoc)) {
// Remove the node if it is an empty text node
if (node.nodeType == Ci.nsIDOMNode.TEXT_NODE && node.nodeValue.trim() == "")
node.parentNode.removeChild(node);
}

for (let containerElement in elementChildren(overlayDoc.documentElement)) {
for (let containerElement of elementChildren(overlayDoc.documentElement)) {
if (!containerElement.id)
continue;

Expand All @@ -252,7 +253,7 @@ const OverlayManagerInternal = {

// TODO apply attributes to the target element

for (let newElement in elementChildren(containerElement)) {
for (let newElement of elementChildren(containerElement)) {
let insertBefore = null;

if (newElement.hasAttribute("insertbefore")) {
Expand Down Expand Up @@ -309,7 +310,7 @@ const OverlayManagerInternal = {
try {
// First check over the new overlays, merge them into the master list
// and if any are for already tracked windows apply them
for (let [windowURL, newOverlays] in Iterator(aOverlayList)) {
for (let windowURL in aOverlayList) {
let newOverlays = aOverlayList[windowURL];

if (!(windowURL in this.overlays))
Expand Down

0 comments on commit 9f41930

Please sign in to comment.