diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3304fbd248eed879b78b9aeed385cd14b0672264..3a6e9c6c1155cf939bb3b92c522dae9ff7e27fe4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -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 diff --git a/shared/links.js b/shared/links.js index 0a9fe5afbf67ec9d8479aa2731841aa64c2ddfa0..a3e65891a846f1de1eaccf2274d7e40f0f0e103e 100644 --- a/shared/links.js +++ b/shared/links.js @@ -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); } } diff --git a/shared/menu.js b/shared/menu.js index 6dd91cdca89c76ba80dff9e9392e8e3e65810ba6..8e5f4deb587388f2a080f8dd083829b910a07daa 100644 --- a/shared/menu.js +++ b/shared/menu.js @@ -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", diff --git a/shared/mutation.js b/shared/mutation.js index af84bc644e8950f4a91a47b73e68d8c94d6e91e1..4080b6a9fa92393f5cbe39e3af2ed953e918d707 100644 --- a/shared/mutation.js +++ b/shared/mutation.js @@ -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 }