Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions chromium/pages/cancel/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ <h1 id="https-everywhere">
<p id="url-paragraph">
<span id="url-label">URL: </span><span id="url-value"></span>
</p>
<button id="copy-url" data-i18n="cancel_copy_url"></button>

<div class="actions">
<button id="open-url-button" data-i18n="cancel_open_page"></button>
Expand Down
3 changes: 1 addition & 2 deletions chromium/pages/cancel/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ h1 img {
}

#url-paragraph {
display: block;
display: inline-flex;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
Expand All @@ -33,7 +33,6 @@ button {
color: #fff;
cursor: pointer;
padding: 0.5em 1em;
display: block;
float: none;
font-size: 12pt;
margin: 8px 0;
Expand Down
56 changes: 56 additions & 0 deletions chromium/pages/cancel/ux.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function displayURL() {
const originURLLink = document.getElementById('url-value');
const openURLButton = document.getElementById('open-url-button');
const openHttpOnce = document.getElementById('http-once-button');
const copyButton = document.getElementById('copy-url');
const url = new URL(originURL);

originURLLink.innerText = originURL;
Expand All @@ -60,6 +61,61 @@ function displayURL() {
return false;
});

// Copy URL Feature on EASE

function copyLinkAlternate() {
let isSuccessful = false;

const sel = window.getSelection();

try {
sel.removeAllRanges();

const range = document.createRange();
range.selectNode(originURLLink);

sel.addRange(range);

isSuccessful = document.execCommand("copy");

sel.removeAllRanges();

return isSuccessful;
} catch (err) {
console.error(err);

sel.removeAllRanges();

return false;
}
}

async function copyLink() {
try {
await navigator.clipboard.writeText(originURL);
return true;
} catch (err) {
return copyLinkAlternate();
}
}

let restoreTimeout = null;

copyButton.addEventListener("click", async () => {
if (await copyLink()) {
copyButton.innerText = chrome.i18n.getMessage("cancel_copied_url");

if (restoreTimeout !== null) {
clearTimeout(restoreTimeout);
}

restoreTimeout = setTimeout(() => {
copyButton.innerText = chrome.i18n.getMessage("cancel_copy_url");
restoreTimeout = null;
}, 1500);
}
});

openHttpOnce.addEventListener("click", function() {
if (confirm(chrome.i18n.getMessage("chrome_disable_on_this_site") + '?')) {
sendMessage("disable_on_site_once", url.host, () => {
Expand Down
2 changes: 2 additions & 0 deletions src/chrome/locale/en/https-everywhere.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@

<!ENTITY https-everywhere.cancel.he_blocking_explainer "HTTPS Everywhere noticed you were navigating to a non-HTTPS page, and tried to send you to the HTTPS version instead. The HTTPS version is unavailable. Most likely this site does not support HTTPS, but it is also possible that an attacker is blocking the HTTPS version. If you wish to view the unencrypted version of this page, you can still do so by disabling the 'Encrypt All Sites Eligible' (EASE) option in your HTTPS Everywhere extension. Be aware that disabling this option could make your browser vulnerable to network-based downgrade attacks on websites you visit.">
<!ENTITY https-everywhere.cancel.he_blocking_network "network-based downgrade attacks">
<!ENTITY https-everywhere.cancel.copy_url "Copy URL">
<!ENTITY https-everywhere.cancel.copied_url "Copied to Clipboard">
<!ENTITY https-everywhere.cancel.open_page "Open insecure page">
<!ENTITY https-everywhere.cancel.http_once "Open insecure page for this session only">

Expand Down