Skip to content

Commit

Permalink
Add Copy for Bug link
Browse files Browse the repository at this point in the history
Start of #3
  • Loading branch information
ericlaw1979 committed Mar 29, 2016
1 parent 18c6f42 commit eeac433
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ a.pageCannotUpgrade { color: black; cursor: default; text-decoration:none; }
#divFooter { width:100%; margin-top:20px; text-align:right; -webkit-user-select: none;}
#lnkTips { display: none; color: grey; font-size: xx-small; text-align: right; margin-right: 10px; }
#lnkUnmark { display: none; color: blue; font-size: xx-small; text-align: right; cursor: pointer; margin-right: 10px; }
#lnkCopyForBug { display: none; color: blue; font-size: xx-small; text-align: right; cursor: pointer; margin-right: 10px; }
#lblVersion { width: 100%; color: blue; font-size: xx-small; text-align: right; cursor: pointer; }
2 changes: 1 addition & 1 deletion popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ <h1>moarTLS Analyzer</h1>
<div style="font-family: monospace; font-size: small" id="divUnsecureList"></div>

<div id="divFooter"><span id="lnkTips">Alt+Click items to check if HTTPS would've worked</span>
<span id="lnkUnmark">Clear Page</span><span id="lblVersion"></span></div>
<span id="lnkUnmark">Clear Page</span><span id="lnkCopyForBug">Copy</span><span id="lblVersion"></span></div>
</body>
</html>
24 changes: 21 additions & 3 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ document.addEventListener('DOMContentLoaded', function() {
const lnkVersion = document.getElementById("lblVersion");
lnkVersion.textContent = "v"+chrome.runtime.getManifest().version;
lnkVersion.addEventListener("click", function() { chrome.runtime.openOptionsPage(); }, false);
}

{
const lnkCopyForBug = document.getElementById("lnkCopyForBug");
lnkCopyForBug.addEventListener("click", function() { copyForBug(); }, false);

const lnkUnmark = document.getElementById("lnkUnmark");
lnkUnmark.addEventListener("click", function() {
lnkUnmark.addEventListener("click", function() {
lnkUnmark.textContent = "";
chrome.tabs.executeScript(null, {code:"{const u = document.querySelectorAll('.moarTLSUnsecure');for (let i = 0; i < u.length; i++) u[i].classList.remove('moarTLSUnsecure');}", allFrames: true, runAt:"document_idle"}, null);
}, false);
Expand Down Expand Up @@ -111,6 +112,22 @@ document.addEventListener('DOMContentLoaded', function() {
});
}, false);

function copyForBug()
{
const copyFrom = document.createElement("textarea");

// TODO: Generate a proper report
copyFrom.textContent = document.body.textContent;
document.body.appendChild(copyFrom);
copyFrom.focus();
copyFrom.select();
document.execCommand('Copy', false, null);
copyFrom.remove();
const lnkCopyForBug = document.getElementById("lnkCopyForBug");
lnkCopyForBug.textContent = "copied!";
setTimeout(function() { lnkCopyForBug.innerHTML = "Copy"; }, 450);
}

function computeDisplayString(cInsecure, cTotal)
{
if (cTotal < 1) return "This page does not contain any links.";
Expand Down Expand Up @@ -217,6 +234,7 @@ chrome.runtime.onMessage.addListener( function(request, sender, sendResponse) {
if (bAnyInsecure) {
document.body.style.backgroundColor = "#FFFF40";
document.getElementById("lnkUnmark").style.display="inline";
document.getElementById("lnkCopyForBug").style.display="inline";
document.getElementById("lnkTips").style.display="inline";
}
else
Expand Down

0 comments on commit eeac433

Please sign in to comment.