Skip to content

Commit 216d221

Browse files
authored
Merge pull request #36 from CryptoScamDB/block-explorer-fixes
Block explorer fixes + address list fixes
2 parents a8b8fbe + 5bd38c9 commit 216d221

File tree

5 files changed

+82
-59
lines changed

5 files changed

+82
-59
lines changed

src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export const serve = async (): Promise<void> => {
156156
id: req.params.id,
157157
entry: entry.result,
158158
domainurl: 'https://cryptoscamdb.org/scam/' + encodeURIComponent(req.params.id),
159-
startTime: startTime
159+
startTime
160160
});
161161
} else {
162162
res.render('404');

src/views/partials/search.ejs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,14 @@
3535
<p id='neutralmessage' class="message-content">This domain wasn't recognized as a malicious domain, nor as verified. Be careful!</p>
3636
</div>
3737
</div>
38+
<div id='help' class="message message-grid">
39+
<i class="info circle icon"></i>
40+
<div class="content message-grid">
41+
<div class="message-label header">
42+
Error.
43+
</div>
44+
<p id='helpmessage' class="message-content">This search query was unknown.</p>
45+
</div>
46+
</div>
3847
</div>
3948
<script src="/js/search.js"></script>

src/views/static/css/search.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
display: none;
2323
}
2424

25+
#help {
26+
display: none;
27+
}
28+
2529
.search-content {
2630
margin-top: 5%;
2731
margin-bottom: 5%;

src/views/static/js/address.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ window.addEventListener("load", function() {
99
$("#notice").html("<div class='ui mini green message'>This is a verified address</div>");
1010
}
1111
if(data.result.entries.length > 0) {
12-
const list = $("<div class='ui bulleted list flex-cent'></div>");
12+
const list = $("<ul class='ui bulleted list'></li>");
1313
data.result.entries.forEach(function(entry) {
1414
if(entry.type == "verified") {
15-
list.append("<div class='item'><a href='" + entry.url + "'>" + entry.name + "</a> (verified)</div>");
15+
list.append("<li class='item'><a href='" + entry.url + "'>" + entry.name + "</a> (verified)</li>");
1616
} else {
17-
list.append("<div class='item'><a href='/scam/" + entry.id + "/'>" + entry.name + "</a></div>");
17+
list.append("<li class='item'><a href='/scam/" + entry.id + "/'>" + entry.name + "</a></li>");
1818
}
1919
});
2020
$("#related-list").html(list);

src/views/static/js/search.js

Lines changed: 65 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,71 @@
11
function hideEverything() {
2-
$("#verified").hide();
3-
$("#blocked").hide();
4-
$("#neutral").hide();
5-
$("#helpmessage").hide();
2+
$("#verified").hide();
3+
$("#blocked").hide();
4+
$("#neutral").hide();
5+
$("#help").hide();
66
}
77

88

99
window.addEventListener("load", function() {
10-
$('.search-btn').click(function() {
11-
console.log('button click recorded')
12-
$.getJSON("https://api.cryptoscamdb.org/v1/check/" + encodeURIComponent($("input").val().toLowerCase().replace('http://','').replace('https://','').replace('www.','').split(/[/?#]/)[0]), function(result) {
13-
if (result.result.status === 'verified') {
14-
hideEverything();
15-
var strLinkVerified = '';
16-
$("#verifiedmessage").html('<b>' + encodeURI($("input").val().toLowerCase().replace('http://','').replace('https://','').replace('www.','').split(/[/?#]/)[0]) + '</b> is a verified domain. You can trust the contents.');
17-
strLinkVerified = '<a id="details" href="/domain/' + encodeURI($("input").val()) + '">Details on this domain <i class="chevron right small icon"></i></a>';
18-
$("#verifiedmessage").html($("#verifiedmessage").html() + ' ' + strLinkVerified);
19-
$("#verified").css('display', 'flex');
20-
} else if (result.result.status === 'neutral') {
21-
hideEverything();
22-
var strLinkNeutral = '';
23-
if(result.result.type === 'address'){
24-
$("#neutralmessage").html('<b>' + encodeURI($("input").val().toLowerCase().replace('http://','').replace('https://','').replace('www.','').split(/[/?#]/)[0]) + '</b> wasn\'t a recognized ETH address.');
25-
strLinkNeutral = '<a id="details" href="https://etherscan.io/address/' + encodeURI($("input").val()) + '">View this address on Etherscan <i class="chevron right small icon"></i></a>';
26-
$("#neutralmessage").html($("#neutralmessage").html() + ' ' + strLinkNeutral);
27-
$("#neutral").css('display', 'flex');
28-
}
29-
else{
30-
$("#neutralmessage").html('<b>' + encodeURI($("input").val().toLowerCase().replace('http://','').replace('https://','').replace('www.','').split(/[/?#]/)[0]) + '</b> wasn\'t recognized as a malicious domain, nor as verified domain. Be careful!');
31-
strLinkNeutral = '<a id="details" href="/domain/' + encodeURI($("input").val()) + '">Details on this domain <i class="chevron right small icon"></i></a>';
32-
$("#neutralmessage").html($("#neutralmessage").html() + ' ' + strLinkNeutral);
33-
$("#neutral").css('display', 'flex');
34-
}
35-
} else if (result.result.status === 'whitelisted') {
36-
hideEverything();
37-
var strLinkWhitelisted = '';
38-
$("#verifiedmessage").html('<b>' + encodeURI($("input").val().toLowerCase().replace('http://','').replace('https://','').replace('www.','').split(/[/?#]/)[0]) + '</b> is a whitelisted address. You can trust it.');
39-
strLinkWhitelisted = '<a id="details" href="/address/' + encodeURI($("input").val()) + '">Details on this address <i class="chevron right small icon"></i></a>';
40-
$("#verifiedmessage").html($("#verifiedmessage").html() + ' ' + strLinkWhitelisted);
41-
$("#verified").css('display', 'flex');
42-
} else if (result.result.status === 'blocked') {
43-
hideEverything();
44-
blocked = true;
45-
var strLinkBlocked = '';
46-
if (result.result.type === 'domain' && 'category' in result.result.entries[0]) {
47-
$("#blacklistmessage").html('<b>' + encodeURI($("input").val().toLowerCase().replace('http://','').replace('https://','').replace('www.','').split(/[/?#]/)[0]) + '</b> was put on the blacklist for ' + result.result.entries[0].category.toLowerCase() + '.');
48-
strLinkBlocked = '<a id="details" href="/domain/' + encodeURI($("input").val()) + '">Details on this domain <i class="chevron right small icon"></i></a>';
49-
} else if(result.result.type === 'address') {
50-
$("#blacklistmessage").html('<b>' + encodeURI($("input").val().toLowerCase()) + ' was put on the blacklist and is associated with '+ result.result.entries.length +' blocked domain(s).');
51-
strLinkBlocked = '<a id="details" href="/address/' + encodeURI($("input").val()) + '">Details on this address <i class="chevron right small icon"></i></a>';
52-
} else if(result.result.type === 'ip') {
53-
$("#blacklistmessage").html('<b>' + encodeURI($("input").val().toLowerCase().replace('http://','').replace('https://','').replace('www.','').split(/[/?#]/)[0]) + '</b> was put on the blacklist and is associated with '+ result.result.entries.length +' blocked domain(s)');
54-
strLink = '<a id="details" href="/ip/' + encodeURI($("input").val()) + '">Details on this domain <i class="chevron right small icon"></i></a>';
55-
}
56-
$("#blacklistmessage").html($("#blacklistmessage").html() + ' ' + strLinkBlocked);
57-
$("#blocked").css('display', 'flex');
58-
}
59-
});
60-
});
10+
$('.search-btn').click(function() {
11+
var encodedSearch = encodeURIComponent($("input").val().replace('http://','').replace('https://','').replace('www.','').split(/[/?#]/)[0]);
12+
var secondEncodedSearch = encodeURI($("input").val().toLowerCase().replace('http://','').replace('https://','').replace('www.','').split(/[/?#]/)[0]);
13+
$.getJSON("https://api.cryptoscamdb.org/v1/check/" + encodedSearch, function(result) {
14+
if (result.success) {
15+
if (result.result.status === 'verified') {
16+
hideEverything();
17+
var strLinkVerified = '';
18+
$("#verifiedmessage").html('<b>' + secondEncodedSearch + '</b> is a verified domain. You can trust the contents.');
19+
strLinkVerified = '<a id="details" href="/domain/' + encodeURI($("input").val()) + '">Details on this domain <i class="chevron right small icon"></i></a>';
20+
$("#verifiedmessage").html($("#verifiedmessage").html() + ' ' + strLinkVerified);
21+
$("#verified").css('display', 'flex');
22+
} else if (result.result.status === 'neutral') {
23+
hideEverything();
24+
var strLinkNeutral = '';
25+
if(result.result.type === 'address'){
26+
$.getJSON("https://api.cryptoscamdb.org/v1/coininfo/" + result.coin, function(coininfo) {
27+
$("#neutralmessage").html('<b>' + secondEncodedSearch + '</b> wasn\'t a recognized ' + result.coin + ' address.');
28+
strLinkNeutral = '<a id="details" target="_blank" href="' + coininfo.result.blockExplorer + $("input").val() + '">View this address on a block explorer <i class="chevron right small icon"></i></a>';
29+
$("#neutralmessage").html($("#neutralmessage").html() + ' ' + strLinkNeutral);
30+
$("#neutral").css('display', 'flex');
31+
});
32+
}
33+
else{
34+
$("#neutralmessage").html('<b>' + secondEncodedSearch + '</b> wasn\'t recognized as a malicious domain, nor as verified domain. Be careful!');
35+
strLinkNeutral = '<a id="details" href="/domain/' + encodeURI($("input").val()) + '">Details on this domain <i class="chevron right small icon"></i></a>';
36+
$("#neutralmessage").html($("#neutralmessage").html() + ' ' + strLinkNeutral);
37+
$("#neutral").css('display', 'flex');
38+
}
39+
} else if (result.result.status === 'whitelisted') {
40+
hideEverything();
41+
var strLinkWhitelisted = '';
42+
$("#verifiedmessage").html('<b>' + secondEncodedSearch + '</b> is a whitelisted address. You can trust it.');
43+
strLinkWhitelisted = '<a id="details" href="/address/' + encodeURI($("input").val()) + '">Details on this address <i class="chevron right small icon"></i></a>';
44+
$("#verifiedmessage").html($("#verifiedmessage").html() + ' ' + strLinkWhitelisted);
45+
$("#verified").css('display', 'flex');
46+
} else if (result.result.status === 'blocked') {
47+
hideEverything();
48+
blocked = true;
49+
var strLinkBlocked = '';
50+
if (result.result.type === 'domain' && 'category' in result.result.entries[0]) {
51+
$("#blacklistmessage").html('<b>' + secondEncodedSearch + '</b> was put on the blacklist for ' + result.result.entries[0].category.toLowerCase() + '.');
52+
strLinkBlocked = '<a id="details" href="/domain/' + encodeURI($("input").val()) + '">Details on this domain <i class="chevron right small icon"></i></a>';
53+
} else if(result.result.type === 'address') {
54+
$("#blacklistmessage").html('<b>' + encodeURI($("input").val().toLowerCase()) + ' was put on the blacklist and is associated with '+ result.result.entries.length +' blocked domain(s).');
55+
strLinkBlocked = '<a id="details" href="/address/' + encodeURI($("input").val()) + '">Details on this address <i class="chevron right small icon"></i></a>';
56+
} else if(result.result.type === 'ip') {
57+
$("#blacklistmessage").html('<b>' + secondEncodedSearch + '</b> was put on the blacklist and is associated with '+ result.result.entries.length +' blocked domain(s)');
58+
strLink = '<a id="details" href="/ip/' + encodeURI($("input").val()) + '">Details on this domain <i class="chevron right small icon"></i></a>';
59+
}
60+
$("#blacklistmessage").html($("#blacklistmessage").html() + ' ' + strLinkBlocked);
61+
$("#blocked").css('display', 'flex');
62+
}
63+
} else {
64+
hideEverything();
65+
strLink = 'Error: ' + result.message + '.'
66+
$("#helpmessage").html($("#helpmessage").html() + '<br>' + strLink);
67+
$("#help").css('display', 'flex');
68+
}
69+
});
70+
});
6171
});

0 commit comments

Comments
 (0)