From 2174f07682f875ef6ea140c6ffe4b099e76293db Mon Sep 17 00:00:00 2001 From: David Byers <david.byers@liu.se> Date: Mon, 25 Jan 2021 13:07:22 +0100 Subject: [PATCH] Updated comments and readme. --- README.md | 34 +++++++++++++++++++++------------- extension/background.js | 24 ++++++++++++++++++++++++ extension/common.js | 24 ++++++++++++++++++++++++ extension/compose.js | 25 +++++++++++++++++++++++-- extension/display.js | 25 +++++++++++++++++++++++-- extension/manifest.json | 2 +- extension/style.css | 23 +++++++++++++++++++++++ 7 files changed, 139 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index c99d6c9..8be4787 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,29 @@ -# Safelinks Cleaner MailExtension +# Microsoft ATP Safe Links Cleaner for Thunderbird -This project is a MailExtension that cleans up display of Microsoft -Advanced Threat Protection Safe Links. +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. -* Displayed plain text links are replaced by the original link. +* Links in plain text email are changed so the original link is + displayed. -* A tooltip is added to all rewritten links to display the original link. +* A tooltip showing the original link is atted to all rewritten links. +* The context menu for rewritten links has a "copy original link item". -## Development +* When responding to a message, rewritten links are replaced by the + original links. -Documentation on add-on development: - -* https://developer.thunderbird.net/add-ons/about-add-ons - -Debugging Thunderbird extensions (ue Ctrl+Shift+I): - -* https://developer.thunderbird.net/add-ons/tips-and-tricks +## 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 + want to visit the original link or the safe link. Due to the way the + tooltip is constructed, visiting the original link will most likely + fail. This is not by design and may change in the future. +* 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. diff --git a/extension/background.js b/extension/background.js index 534b37e..9d9957c 100644 --- a/extension/background.js +++ b/extension/background.js @@ -1,3 +1,27 @@ +// Microsoft 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. + +// Background scripts + + browser.composeScripts.register({ js: [ {file: "common.js"}, diff --git a/extension/common.js b/extension/common.js index f1fd15f..5b431a5 100644 --- a/extension/common.js +++ b/extension/common.js @@ -1,3 +1,27 @@ +// Microsoft 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. + +// Shared code + + const safelinksRegexp = new RegExp( 'https?://[^.]+[.]safelinks[.]protection[.]outlook[.]com/[?]url=([^&]+)&.*', 'gi' diff --git a/extension/compose.js b/extension/compose.js index 0b1bffc..7cb6213 100644 --- a/extension/compose.js +++ b/extension/compose.js @@ -1,5 +1,26 @@ -// Modify the displayed message to clarify where safelinks are -// inserted and to show the actual link targets. +// Microsoft 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. + +// Compose script + for (const link of document.links) { if (isTangledLink(link.href)) { diff --git a/extension/display.js b/extension/display.js index abae2db..09c4b1d 100644 --- a/extension/display.js +++ b/extension/display.js @@ -1,5 +1,26 @@ -// Modify the displayed message to clarify where safelinks are -// inserted and to show the actual link targets. +// Microsoft 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. + +// Display script + for (const link of document.links) { // Mangle the link text diff --git a/extension/manifest.json b/extension/manifest.json index 8cea9e2..aa813da 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -4,7 +4,7 @@ "description": "__MSG_extensionDescription__", "version": "1.1", "author": "David Byers", - "homepage_url": "https://safelinks.gitlab-pages.liu.se/safelinks-cleaner-mailextension/", + "homepage_url": "https://safelinks.gitlab-pages.liu.se/safelinks-cleaner-thunderbird/", "default_locale": "en", "icons": { "48": "icon.svg", diff --git a/extension/style.css b/extension/style.css index df4e513..169865b 100644 --- a/extension/style.css +++ b/extension/style.css @@ -1,3 +1,26 @@ +/* +Microsoft 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. +*/ + a:hover .liu_safelinks_tooltip { display: block; } -- GitLab