From ddc0c70f18d09083304956f4ef6fc81dc8b77e43 Mon Sep 17 00:00:00 2001
From: David Byers <david.byers@liu.se>
Date: Wed, 3 Feb 2021 12:21:42 +0100
Subject: [PATCH] Clean up names and comments.

---
 README.md                 | 27 +++++++++++++++------------
 firefox/content.js        |  4 ++--
 firefox/mutation.js       | 36 ++++++++++++++++++++++++++++++++++++
 shared/links.js           |  2 +-
 shared/menu.js            |  2 +-
 shared/popup.js           |  2 +-
 shared/style.css          |  2 +-
 thunderbird/background.js |  2 +-
 thunderbird/compose.js    |  2 +-
 thunderbird/display.js    |  2 +-
 10 files changed, 60 insertions(+), 21 deletions(-)

diff --git a/README.md b/README.md
index 580cee7..1a42a09 100644
--- a/README.md
+++ b/README.md
@@ -1,27 +1,30 @@
-# Microsoft ATP Safe Links Cleaner for Thunderbird
+# ATP Safe Links Cleaner
 
-This Thunderbird extension cleans up the display of links rewritten by
-Microsoft Advanced Threat Protection. Unlike many similar extensions
-it does not change the links, but does ensure that they are displayed
-in such a way that the original link is accessible.
+This extension cleans up the display of links rewritten by Microsoft
+Defender for Office 365 Advanced Threat Protection. Unlike many
+similar extensions it does not change the links, but does ensure that
+they are displayed in such a way that the original link is accessible.
+
+The extension currently builds for Thunderbird and Firefox (it will
+only affect links on outlook.com).
 
 * Links in plain text email are changed so the original link is
   displayed.
 
-* A tooltip showing the original link is atted to all rewritten links.
+* A tooltip showing the original link is added to all rewritten links.
 
 * The context menu for rewritten links has a "copy original link item".
 
-* When responding to a message, rewritten links are replaced by the
-  original links.
+* When responding to a message in Thunderbird, rewritten links are
+  replaced by the original links.
 
 ## Known issues
 
 * Since only the *display* is changed, links that have the URL as the
   link text will now have link text that differs from the link target.
-  Thunderbird picks up on this when you click a link and asks if you
+  This may be picked up on this when you click a link and asks if you
   want to visit the original link or the safe link.
 
-* When composing a message the original links are restored. This
-  process could potentially change text that isn't meant to be
-  changed but looks almost like a valid safe link.
+* When composing a message in Thunderbird the original links are
+  restored. This process could potentially change text that isn't
+  meant to be changed but looks almost like a valid safe link.
diff --git a/firefox/content.js b/firefox/content.js
index 3fe7f87..ecbb37e 100644
--- a/firefox/content.js
+++ b/firefox/content.js
@@ -1,4 +1,4 @@
-// Microsoft ATP Safe Links Cleaner
+// ATP Safe Links Cleaner
 // Copyright 2021 David Byers <david.byers@liu.se>
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -19,7 +19,7 @@
 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 // SOFTWARE.
 
-// Display script
+// Content script
 
 
 /**
diff --git a/firefox/mutation.js b/firefox/mutation.js
index 746dbb7..781085a 100644
--- a/firefox/mutation.js
+++ b/firefox/mutation.js
@@ -1,6 +1,33 @@
+// ATP Safe Links Cleaner
+// Copyright 2021 David Byers <david.byers@liu.se>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+// 
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+// Mutation observer for web browsers
+
+
 let mutationObserver = null;
 
 
+/**
+ * Enable the mutation observer, creating it is necessary.
+ */
 function enableMutationObserver() {
     console.log('enter enableMutationObserver');
     if (!mutationObserver) {
@@ -13,6 +40,9 @@ function enableMutationObserver() {
     console.log('exit enableMutationObserver');
 }
 
+/**
+ * Disable the mutation observer if it is enabled
+ */
 function disableMutationObserver() {
     console.log('enter disableMutationObserver');
     if (mutationObserver) {
@@ -21,6 +51,12 @@ function disableMutationObserver() {
     console.log('exit disableMutationObserver');
 }
 
+/**
+ * Wrap a function in code that disables the mutation observer.
+ *
+ * @param {function} func - The function to wrap.
+ * @returns {function} The wrapped function.
+ */
 function withoutMutationObserver(func) {
     return (...args) => {
 	try {
diff --git a/shared/links.js b/shared/links.js
index 27ffc30..b277fd4 100644
--- a/shared/links.js
+++ b/shared/links.js
@@ -1,4 +1,4 @@
-// Microsoft ATP Safe Links Cleaner
+// ATP Safe Links Cleaner
 // Copyright 2021 David Byers <david.byers@liu.se>
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/shared/menu.js b/shared/menu.js
index 3f77416..a4f766d 100644
--- a/shared/menu.js
+++ b/shared/menu.js
@@ -1,4 +1,4 @@
-// Microsoft ATP Safe Links Cleaner
+// ATP Safe Links Cleaner
 // Copyright 2021 David Byers <david.byers@liu.se>
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/shared/popup.js b/shared/popup.js
index d1a6aec..052db2d 100644
--- a/shared/popup.js
+++ b/shared/popup.js
@@ -1,4 +1,4 @@
-// Microsoft ATP Safe Links Cleaner
+// ATP Safe Links Cleaner
 // Copyright 2021 David Byers <david.byers@liu.se>
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/shared/style.css b/shared/style.css
index 95f271c..3ba19a9 100644
--- a/shared/style.css
+++ b/shared/style.css
@@ -1,5 +1,5 @@
 /*
-Microsoft ATP Safe Links Cleaner
+ATP Safe Links Cleaner
 Copyright 2021 David Byers <david.byers@liu.se>
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/thunderbird/background.js b/thunderbird/background.js
index e85a042..f6b76b6 100644
--- a/thunderbird/background.js
+++ b/thunderbird/background.js
@@ -1,4 +1,4 @@
-// Microsoft ATP Safe Links Cleaner
+// ATP Safe Links Cleaner
 // Copyright 2021 David Byers <david.byers@liu.se>
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/thunderbird/compose.js b/thunderbird/compose.js
index 7cb6213..f9a8c15 100644
--- a/thunderbird/compose.js
+++ b/thunderbird/compose.js
@@ -1,4 +1,4 @@
-// Microsoft ATP Safe Links Cleaner
+// ATP Safe Links Cleaner
 // Copyright 2021 David Byers <david.byers@liu.se>
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
diff --git a/thunderbird/display.js b/thunderbird/display.js
index 2f8061b..813f6b8 100644
--- a/thunderbird/display.js
+++ b/thunderbird/display.js
@@ -1,4 +1,4 @@
-// Microsoft ATP Safe Links Cleaner
+// ATP Safe Links Cleaner
 // Copyright 2021 David Byers <david.byers@liu.se>
 //
 // Permission is hereby granted, free of charge, to any person obtaining a copy
-- 
GitLab