Skip to content
Snippets Groups Projects
Commit acdc4e68 authored by David Byers's avatar David Byers
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
Pipeline #31603 failed
*~
\#*
.#*
safelinks-cleaner-thunderbird.xpi
---
stages:
- build
- deploy
build:
stage: build
script:
- cd extension
- zip -r ../safelinks-cleaner-thunderbird.xpi *
artifacts:
- ./safelinks-cleaner-thunderbird.xpi
pages:
stage: deploy
script:
- mkdir .public
- cp -r site .public
- cp safelinks-cleaner-thunderbird.xpi .public
- mv .public public
- ls -lr public
artifacts:
paths:
- public/
only:
- master
when: always
# Safelinks Cleaner MailExtension
This project is a MailExtension that cleans up display of Microsoft
Advanced Threat Protection Safe Links.
* Displayed plain text links are replaced by the original link.
* A tooltip is added to all rewritten links to display the original link.
## Development
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
extension/assets/shield.png

692 B

browser.messageDisplayScripts.register({
css: [{
file: "/style.css",
}],
js: [{
file: "/content.js",
}],
});
// Modify the displayed message to clarify where safelinks are
// inserted and to show the actual link targets.
const safelinksRegexp = new RegExp(
'https?://[^.]+[.]safelinks[.]protection[.]outlook[.]com/[?]url=([^&]+)&.*',
'gi'
);
function getTextNodes(elem) {
var result = [];
if (elem) {
for (var nodes = elem.childNodes, i = nodes.length; i--;) {
let node = nodes[i];
let nodeType = node.nodeType;
if (nodeType == Node.TEXT_NODE) {
result.push(node);
}
else if (nodeType == Node.ELEMENT_NODE
|| nodeType == Node.DOCUMENT_NODE
|| nodeType == Node.DOCUMENT_FRAGMENT_NODE) {
result = result.concat(getTextNodes(node));
}
}
}
return result;
}
for (const link of document.links) {
let display = link.innerHTML;
// Mangle the link text
for (const node of getTextNodes(link)) {
node.textContent = node.textContent.replaceAll(
safelinksRegexp, (match, url) => {
try {
return decodeURIComponent(url);
}
catch (e) {
return url;
}
});
}
// Generate the tooltip and set link class
for (const match of link.href.matchAll(safelinksRegexp)) {
link.classList.add('liu_safelinks_link');
let tooltiptext = match[1];
let tooltip = document.createElement('span');
tooltip.classList.add('liu_safelinks_tooltip');
try {
tooltiptext = decodeURIComponent(tooltiptext);
}
catch (e) {
}
tooltip.textContent = tooltiptext;
link.appendChild(tooltip);
break;
}
}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><defs><linearGradient id="0" gradientUnits="userSpaceOnUse" y1="227.63" x2="0" y2="171.63"><stop stop-color="#2fae61"/><stop offset="1" stop-color="#4bdf88"/></linearGradient></defs><g transform="matrix(.92857 0 0 .92857-676.99-152.79)"><path d="m789.32 182.93c-.017-1.302-1.019-2.377-2.315-2.496-10.772-1.01-19.563-6.764-22.461-8.87-.606-.442-1.426-.442-2.032 0-2.893 2.106-11.683 7.863-22.456 8.87-1.296.119-2.293 1.194-2.315 2.496-.13 8.497 1.234 37.34 25.14 43.762.425.113.872.113 1.296 0 23.905-6.413 25.27-35.27 25.14-43.762" fill="url(#0)"/><path d="m773.85 193.97l-1.89-1.89c-.259-.259-.574-.389-.945-.389-.371 0-.686.13-.945.389l-9.116 9.13-4.085-4.099c-.259-.259-.574-.389-.945-.389-.371 0-.686.13-.945.389l-1.89 1.89c-.259.259-.389.574-.389.945 0 .37.13.686.389.945l5.03 5.03 1.89 1.89c.259.259.574.389.945.389.37 0 .685-.13.945-.389l1.89-1.89 10.06-10.06c.259-.259.389-.574.389-.945 0-.37-.13-.685-.389-.945" fill="#fff" fill-opacity=".851"/></g></svg>
{
"manifest_version": 2,
"name": "Safelinks Cleaner",
"description": "Clean up display of Microsoft Advanced Threat Protection Safe Links",
"version": "1.0",
"author": "David Byers",
"homepage_url": "https://gitlab.liu.se/davby02/safelinkscleaner/",
"icons": {
"48": "icon.svg",
"96": "icon.svg",
"144": "icon.svg",
"192": "icon.svg"
},
"applications": {
"gecko": {
"id": "safelinkscleaner@it.liu.se",
"strict_min_version": "78.4"
}
},
"background": {
"scripts": [
"background.js"
]
},
"permissions": [
"messagesModify"
],
"web_accessible_resources": [
"assets/*.png"
]
}
a:hover .liu_safelinks_tooltip {
display: block;
}
.liu_safelinks_tooltip {
display: none;
background: #fffff0 url(assets/shield.png) no-repeat 3px;
background-size: 14px 14px;
color: black;
padding: 3px 3px 4px 22px;
position: absolute;
z-index: 1000;
border: 1px solid black;
-webkit-box-shadow: 0px 0px 6px 1px rgba(0,0,0,0.5);
-moz-box-shadow: 0px 0px 6px 1px rgba(0,0,0,0.5);
box-shadow: 0px 0px 6px 1px rgba(0,0,0,0.5);
font: 14px sans-serif;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment