diff --git a/README.md b/README.md index c99d6c9dea50c6d10bbab9ae62e15ca7e667baf8..8be4787f1882eec74bbaf1619037b68b2b68cced 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 534b37e511439d749e9d7720240088c5068e34a3..9d9957cfdd949a06179f89db9b7d88e4060232d7 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 f1fd15f857447a4367562fd0aeb9f707e62e44d9..5b431a51069965cde5005841477edbe8109606c5 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 0b1bffca7b4fd99706b9ee4429adb10d59199d6d..7cb6213c60238da1cbb2381d386df9858c899175 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 abae2dbff3259fe10f33507cb388448aba52d55a..09c4b1d1ebe4d20efbf541612b2f0797c665643f 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 8cea9e2e332f9cfa82d191ca7ed10b58dbbb6410..aa813dab664f7335a67758b389d8d35344388333 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 df4e5138cd52da3259d79171c8a29859454a9569..169865b4f8977b689d0d752f02bf3741cc776f40 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; }