Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
Change the link to a highlight-on-click span
Browse files Browse the repository at this point in the history
  • Loading branch information
patch-malone committed Feb 1, 2019
1 parent 75ddf2f commit 4267baf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion chromium/pages/cancel/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<h1 id="https-everywhere"><img src="../../images/banner-red.png" alt="HTTPS Everywhere" /></h1>
<p data-i18n="cancel_he_blocking_explainer"></p>
<p id="url-paragraph">
<span id="url-label">URL: </span><a href="#" id="url-value">PLACEHOLDER</a>
<span id="url-label">URL: </span><span id="url-value">PLACEHOLDER</span>
</p>
<p class="actions">
<a href="#" id="open-url-button" data-i18n="cancel_add_rule_and_open_insecurely">Open insecurely and do not ask again</a>
Expand Down
18 changes: 17 additions & 1 deletion chromium/pages/cancel/ux.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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();

Expand Down

0 comments on commit 4267baf

Please sign in to comment.