Skip to content

Commit

Permalink
Merge branch 'ft-history_checker'
Browse files Browse the repository at this point in the history
* ft-history_checker:
  Removed debug
  Increased version number
  Added logic to remove history permission after using it
  Added message to say you're good and fixed the permission not granted view bug
  Added note styling
  More styling
  Added logic to perform a history check
  Added URI lib - thanks to https://github.com/medialize/URI.js
  Added optional permission of history
  Added better styling for settings.html and history checker functionality
  • Loading branch information
409H committed Sep 14, 2017
2 parents e937b10 + f84f954 commit 9598b15
Show file tree
Hide file tree
Showing 7 changed files with 418 additions and 57 deletions.
123 changes: 69 additions & 54 deletions css/settings.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions css/settings.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

116 changes: 116 additions & 0 deletions css/settings.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
$main_background: #00c2c1;
$main_color: #fff;

$u_background: #fff;
$u_color: #000;

$error_background: #fff;
$error_color: #c2654c;

$warning_background: #ffe700;
$warning_color: #a98500;

$success_background: #49bd51;
$success_color: #fff;

body {
background: $main_background;
padding: 50px;
font-family: 'Montserrat', sans-serif;
color: $main_color;
font-weight: 600;

.hide-me {
display: none;
}

h3 {
font-size: 23pt;
}
}

.pure-g {
margin-bottom: 5%;

.pure-u-1-3, .pure-u-2-3, .pure-u-1-1 {
background: $u_background;
color: $u_color;
border: 2px solid darken($main_background, 5%);
padding: 15px;

p {
font-size: 10pt;
font-weight: 500;
color: #b4b4b4;

.label {
font-weight: 700;
}
}
}
}

.pure-table {
width: 100%;
}

.note {
color: #b4b4b4;
font-style: italic;
font-size: 10pt;

&.ext-etheraddresslookup-history_good {
margin: 5px;
color: $main_color;
background: $main_background;
padding: 2px;
}

&.ext-etheraddresslookup-history_bad {
margin: 5px;
color: $main_color;
background: $error_color;
padding: 2px;
}
}

#ext-etheraddresslookup-bookmark_modify_remove {
font-size: 85%;
background: rgb(202, 60, 60);
color: #fff;
}

#donate_address {
font-size: 80%;
background: #fffdfd;
padding: 2px;
border: 1px solid #ffe4e4;
color: #009d9c;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
}

.error {
background: $error_background;
padding: 2px;
color: $error_color;
border: 2px solid darken($error_color, 5%);
text-align: center;
}

.warning {
background: $warning_background;
padding: 2px;
color: $warning_color;
border: 2px solid darken($warning_background, 1%);
text-align: center;
}

.success {
background: $success_background;
padding: 2px;
color: $success_color;
border: 2px solid darken($success_background, 1%);
text-align: center;
}
100 changes: 100 additions & 0 deletions js/app/historyInspector.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
(function () {
var objHistoryInspector = document.getElementById("ext-etheraddresslookup-history_inspect");

//Perform the history inspection
objHistoryInspector.addEventListener("click", function (objEvent) {
//See if we need to request permission
chrome.permissions.contains({
permissions: ['history']
}, function (blResult) {
//No permission to history, ask for it.
if (blResult === false) {
chrome.permissions.request({
permissions: ['history']
}, function (blGranted) {
if (blGranted) {
console.log("Granted history permission");
doHistoryInspection();
} else {
exitNoPermission();
}
});
} else {
doHistoryInspection();
}
});
});
})();

function doHistoryInspection() {
chrome.history.search({text: "", maxResults: 500}, function (objHistoryItems) {
var blRedirected = false;
var intTotalWarnings = 0;
var strReportText = "";

var objBlacklistedDomains = localStorage.getItem("ext-etheraddresslookup-blacklist_domains_list");
objBlacklistedDomains = JSON.parse(objBlacklistedDomains);

var objDiv = document.getElementById("ext-etheraddresslookup-history_inspect_data");
objDiv.innerHTML = "";

for (var intIterator = 0; intIterator < objHistoryItems.length; intIterator++) {
var objUri = URI(objHistoryItems[intIterator].url);

//See if we redirected to the phishing site...
if (objUri.domain() === "harrydenley.com" && objUri.path() === "/EtherAddressLookup/phishing.html") {
blRedirected = true;
continue;
}

//See if the domain is in the phishing list
if (objBlacklistedDomains.domains.indexOf(objUri.domain()) >= 0) {
strReportText += "<span class='note'>" + (new Date(objHistoryItems[intIterator].lastVisitTime).toUTCString()) + "</span>&nbsp;";
//Did EAL redirect you away?
if (blRedirected) {
strReportText += objUri.domain() + "<span class='note ext-etheraddresslookup-history_good'>EAL successfully redirected you away.</span>";
} else {
strReportText += objUri.domain() + "<span class='note ext-etheraddresslookup-history_bad'>Domain is now blacklisted - but wasn't at the time.</span>";
++intTotalWarnings;
}
strReportText += "<span class='note'><small>Visited "+ objHistoryItems[intIterator].visitCount +" times</small></span>";
strReportText += "<br />";
}

blRedirected = false;
}

objDiv.innerHTML = "";
if(intTotalWarnings > 0) {
objDiv.innerHTML += "<div class='warning'>You have been on a domain that has now been blacklisted - if you " +
"entered your private key anywhere on the reported domains below, please consider your address " +
"compromised and start moving your coins to an alternative address that you trust and control!</div><br /><br />"
} else {
objDiv.innerHTML += "<div class='success'>It looks like you're all good! Remember to never share your private keys.</div><br /><br />"
}
objDiv.innerHTML += strReportText;
objDiv.style.display = "inline";

removePermission();
});
}

function exitNoPermission()
{
var objDiv = document.getElementById("ext-etheraddresslookup-history_inspect_data");
objDiv.innerHTML = "<div class='error'>Permission wasn't granted. Cannot inspect history!</div>";
objDiv.classList.remove("hide-me");
}

function removePermission()
{
chrome.permissions.remove({
permissions: ['history']
}, function(removed) {
if (removed) {
console.log("Removed history permission.")
} else {
console.log("Cannot remove history permission!");
}
});
}
Loading

0 comments on commit 9598b15

Please sign in to comment.