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

Add support for Google Chrome.

parent 3c3da63b
No related branches found
No related tags found
No related merge requests found
......@@ -5,13 +5,18 @@ stages:
- collect
- deploy
workflow:
rules:
- if: '$CI_COMMIT_TAG'
when: never
- if: '$CI_PIPELINE_SOURCE != "push"'
when: always
- when: never
# Anchors
.release_rules: &release_rules
rules:
- if: '$CI_COMMIT_TAG'
when: never
- if: '$CI_COMMIT_BRANCH != "master"'
when: never
- if: "$CI_COMMIT_MESSAGE =~ /#release/"
......@@ -21,8 +26,6 @@ stages:
# When changing, also make changes to copies in the build stage
.beta_rules: &beta_rules
rules:
- if: '$CI_COMMIT_TAG'
when: never
- if: '$CI_COMMIT_BRANCH != "master"'
when: never
- if: "$CI_COMMIT_MESSAGE =~ /#release/"
......@@ -31,8 +34,6 @@ stages:
.dev_rules: &dev_rules
rules:
- if: '$CI_COMMIT_TAG'
when: never
- if: '$CI_COMMIT_BRANCH != "master"'
when: always
- when: never
......@@ -103,8 +104,7 @@ build:edge:beta:
extends: .build:edge
variables:
VARIANT: beta
- if: '$CI_COMMIT_TAG'
when: never
rules:
- if: '$CI_COMMIT_BRANCH != "master"'
when: never
- if: "$CI_COMMIT_MESSAGE =~ /#release/"
......@@ -151,8 +151,6 @@ build:firefox:beta:
CHANNEL: unlisted
VARIANT: beta
rules:
- if: '$CI_COMMIT_TAG'
when: never
- if: '$CI_COMMIT_BRANCH != "master"'
when: never
- if: "$CI_COMMIT_MESSAGE =~ /#release/"
......@@ -164,9 +162,6 @@ build:firefox:beta:
- firefox/**/*
when: always
- when: never
artifacts:
paths:
- safelinks-cleaner-thunderbird-$VARIANT.xpi
build:firefox:release:
extends: .build:firefox
......@@ -196,8 +191,7 @@ build:thunderbird:beta:
extends: .build:thunderbird
variables:
VARIANT: beta
- if: '$CI_COMMIT_TAG'
when: never
rules:
- if: '$CI_COMMIT_BRANCH != "master"'
when: never
- if: "$CI_COMMIT_MESSAGE =~ /#release/"
......@@ -208,7 +202,7 @@ build:thunderbird:beta:
- shared/**/*
- thunderbird/**/*
when: always
- when: beta
- when: never
build:thunderbird:release:
extends: .build:thunderbird
......
......@@ -111,19 +111,24 @@ function addLinkPopup(link) {
/**
* Fix all the links in the document.
* @param {Element} root - DOM element in which to fix links.
* @param {Element} is_owa - Set to true when fixing Outlook.
*/
function fixAllTheLinks(root) {
function fixAllTheLinks(root, is_owa) {
console.log('enter fixAllTheLinks'); // DEBUG
for (const link of root.getElementsByTagName('a')) {
console.log(link); // DEBUG
if (link.href) {
let textWasTangled = false;
// Untangle link text
for (const node of getTextNodes(link)) {
node.textContent = untangleLink(node.textContent);
if (isTangledLink(node.textContent)) {
textWasTangled = true;
node.textContent = untangleLink(node.textContent);
}
}
// Create popup event handlers
if (isTangledLink(link.href)) {
if (isTangledLink(link.href) && (!is_owa || textWasTangled)) {
addLinkPopup(link);
}
}
......
......@@ -21,6 +21,15 @@
// Context menu
/*
* Minimal polyfill for Chrome
*/
if (typeof browser === "undefined") {
var browser = {
menus: chrome.contextMenus,
i18n: chrome.i18n,
}
}
browser.menus.create({
id: "liu-safelinks-copy",
......
......@@ -38,7 +38,7 @@ function mutationHandler(mutationsList, observer) {
removeAllTheLinks(contentNode);
contentNode = contentNode.nextElementSibling;
}
fixAllTheLinks(document.body);
fixAllTheLinks(document.body, true);
console.log('exit mutationHandler'); // DEBUG
}
......
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