From 4267baf54e8bbf4a5800a4f41a8cc49a54466c1b Mon Sep 17 00:00:00 2001 From: patch malone <46642059+patch-malone@users.noreply.github.com> Date: Fri, 1 Feb 2019 16:12:41 +0000 Subject: [PATCH] Change the link to a highlight-on-click span --- chromium/pages/cancel/index.html | 2 +- chromium/pages/cancel/ux.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/chromium/pages/cancel/index.html b/chromium/pages/cancel/index.html index 3434d5aa2dac..e57956016d27 100644 --- a/chromium/pages/cancel/index.html +++ b/chromium/pages/cancel/index.html @@ -12,7 +12,7 @@

HTTPS Everywhere

- URL: PLACEHOLDER + URL: PLACEHOLDER

Open insecurely and do not ask again diff --git a/chromium/pages/cancel/ux.js b/chromium/pages/cancel/ux.js index daff3cc3f0e5..d3927406befa 100644 --- a/chromium/pages/cancel/ux.js +++ b/chromium/pages/cancel/ux.js @@ -16,6 +16,19 @@ document.addEventListener("DOMContentLoaded", () => { displayURL(); }); +/** + * Highlights the content (text, images, etc.) of an element + * @param {Element} + * @returns {void} + */ +function highlightElementContent(element) { + if (window.getSelection) { + var range = document.createRange(); + range.selectNode(element); + window.getSelection().addRange(range); + } +} + function replaceLink(explainer) { observer.disconnect(); const linkText = chrome.i18n.getMessage("cancel_he_blocking_network"); @@ -32,9 +45,12 @@ function displayURL() { const openURLButton = document.getElementById('open-url-button'); originURLLink.innerHTML = originURL; - originURLLink.href = originURL; openURLButton.href = originURL; + originURLLink.addEventListener("click", function(event) { + highlightElementContent(event.target); + }); + openURLButton.addEventListener("click", function(event) { event.preventDefault();