|
1 | 1 | 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(); |
6 | 6 | } |
7 | 7 |
|
8 | 8 |
|
9 | 9 | 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 | + }); |
61 | 71 | }); |
0 commit comments