Skip to content

Commit

Permalink
More stuff for release
Browse files Browse the repository at this point in the history
  • Loading branch information
409H committed Feb 4, 2018
1 parent cb876d4 commit 1360cf5
Show file tree
Hide file tree
Showing 17 changed files with 253 additions and 174 deletions.
16 changes: 16 additions & 0 deletions EtherSecurityLookup.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@
<div id="content">
<h4 class="text-center">EtherSecurityLookup</h4>

<a target="_blank" href="https://etherscamdb.info/report/domain/" class="btn btn-sm btn-error"
id="ext-ethersecuritylookup-report"><img width="16" height="16" src="images/flag.png"> Report a domain</a>

<br/>

<label class="fancy-checkbox">
<input type="checkbox" name="ext-ethersecuritylookup-twitter_whitelist_checkbox" id="ext-ethersecuritylookup-twitter_whitelist_checkbox">
<span>Fake Twitter Account Warning</span>
</label>
<div id="ext-ethersecuritylookup-twitter_stats">
<small>Last Updated: <span id="ext-ethersecuritylookup-twitter_whitelist_last_updated">N/A</span></small>
<br/>
<small>Whitelisted Accounts: <span id="ext-ethersecuritylookup-twitter_whitelist_count">0</span></small>
</div>

<br/>
<div id="footer">
<div class="ext-ethersecuritylookup-center">
Expand All @@ -26,5 +41,6 @@ <h4 class="text-center">EtherSecurityLookup</h4>
<strong>Version:</strong> <span id="ext-manifest_version"></span> &mdash; BETA
</div>
</div>
<script src="/js/app/EtherSecurityLookup.js"></script>
</body>
</html>
12 changes: 12 additions & 0 deletions css/EtherSecurityLookup.css

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

2 changes: 1 addition & 1 deletion css/EtherSecurityLookup.css.map

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

19 changes: 19 additions & 0 deletions css/EtherSecurityLookup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@
#content {
padding: 15px;
margin-top: 15px;

.ext-ethersecuritylookup-center {
text-align: center;
}

#ext-ethersecuritylookup-report {
margin-bottom: 20px;
padding: 8px 20px 8px 17px;
width: 100%;
font-size: 10pt;
}

#ext-ethersecuritylookup-twitter_stats {
font-size: 10pt;
color: #c2c6c7;
line-height: 10pt;
padding-left: 3.5em;
}

}

#footer {
Expand Down
Binary file modified images/ether-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/ether-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/ether-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/ether-48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/ether-64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/flag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/icon.png
Binary file not shown.
Empty file removed js/EtherSecurityLookup.js
Empty file.
138 changes: 138 additions & 0 deletions js/app/EtherSecurityLookup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
document.getElementById("ext-manifest_version").innerText = chrome.runtime.getManifest().version;

class EslTools {

async getListFromGithub(objTwitterWhitelist)
{
try {
let objResponse = await fetch(objTwitterWhitelist.repo);
return objResponse.json();
} catch(objError) {
console.error("Failed to get Twitter list: "+ objTwitterWhitelist.repo, objError);
}
}

timeDifference(current, previous)
{
if(previous == 0) {
return "Not fetched";
}

var elapsed = parseInt(current) - parseInt(previous);
if(elapsed > 59) {
return Math.floor(elapsed / 60) + ' minutes ago';
}
return Math.round(elapsed) + ' seconds ago';
}

}

class TwitterLists {

constructor()
{
this.getStats();

setInterval(function() {
this.refreshWhitelist();
}.bind(this), 50000);
}

/**
* Fetches the whitelist from either localstorage or the default strucutre/values.
*
* @return object {{status: number, timestamp: number, repo: string, users: Array}}
*/
getWhitelistStructure()
{
var strTwitterWhitelist = localStorage.getItem("ext-ethersecuritylookup-twitter_whitelist");

if(strTwitterWhitelist === null) {
var objTwitterWhitelist = {
"status": true,
"timestamp": 0,
"repo": "https://gist.githubusercontent.com/409H/740c10d340ec01e265ba4add2e4430a7/raw/f975cf74174a999292c954eb9e1da7cc70956a49/esl-twitter.whitelist.json",
"users": []
};
} else {
var objTwitterWhitelist = JSON.parse(strTwitterWhitelist);
}

return objTwitterWhitelist;
}

/**
* Fetches the whitelist json from the repo and puts it in localstorage
*/
refreshWhitelist()
{
var objEslTools = new EslTools();

var objTwitterWhitelist = this.getWhitelistStructure();

if(objTwitterWhitelist.status) {
objEslTools.getListFromGithub(objTwitterWhitelist).then(function (objList) {
objTwitterWhitelist.timestamp = Math.floor(Date.now() / 1000);
objTwitterWhitelist.users = objList;

localStorage.setItem("ext-ethersecuritylookup-twitter_whitelist", JSON.stringify(objTwitterWhitelist));
this.getStats();
}.bind(this));
}
}

/**
* Gets and formats the stats for EtherSecurityLookup.html
*/
getStats()
{
console.log("GET STATS");
var objTwitterWhitelist = this.getWhitelistStructure();
var objEslTools = new EslTools();

console.log(objTwitterWhitelist);
document.getElementById("ext-ethersecuritylookup-twitter_whitelist_checkbox").checked = objTwitterWhitelist.status;
document.getElementById("ext-ethersecuritylookup-twitter_whitelist_last_updated").innerText = objEslTools.timeDifference(Math.floor(Date.now()/1000), objTwitterWhitelist.timestamp);
document.getElementById("ext-ethersecuritylookup-twitter_whitelist_count").innerText = Object.keys(objTwitterWhitelist.users).length;
}

/**
* Event handler to toggle the twitter option on/off and save into localstorage
*/
toggleOption()
{
var objTwitterWhitelist = this.getWhitelistStructure();
console.log("Check:"+ document.getElementById('ext-ethersecuritylookup-twitter_whitelist_checkbox').checked);
console.log(typeof document.getElementById('ext-ethersecuritylookup-twitter_whitelist_checkbox').checked);
if(document.getElementById('ext-ethersecuritylookup-twitter_whitelist_checkbox').checked) {
objTwitterWhitelist.status = true;
} else {
objTwitterWhitelist.status = false;
}

console.log(objTwitterWhitelist);
localStorage.setItem("ext-ethersecuritylookup-twitter_whitelist", JSON.stringify(objTwitterWhitelist));
}
}

var objTwitterLists = new TwitterLists();
var objTwitterWhitelist = document.getElementById('ext-ethersecuritylookup-twitter_whitelist_checkbox');
if(objTwitterWhitelist) {
objTwitterWhitelist.addEventListener('change', function() {
this.toggleOption();
}.bind(objTwitterLists), false);
}

class DomainBlacklist {

constructor()
{
this.refreshBlacklist();
}

refreshBlacklist()
{

}

}
135 changes: 0 additions & 135 deletions js/patch-worker.js

This file was deleted.

Loading

0 comments on commit 1360cf5

Please sign in to comment.