-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
4 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function scanURLWithVirusTotal(url, tabId, callback) { | ||
const API_KEY = 'd952e200fd50390b51eba3157347d8d44f7be039dbafd8091216fdcf428cda3b'; // Replace with your API key | ||
const API_URL = `https://www.virustotal.com/vtapi/v2/url/report?apikey=${API_KEY}&resource=${url}`; | ||
|
||
fetch(API_URL) | ||
.then(response => { | ||
if (!response.ok) { | ||
throw new Error('Network response was not ok.'); | ||
} | ||
return response.json(); | ||
}) | ||
.then(data => { | ||
if (data.response_code === 0) { | ||
throw new Error('URL not found or no information available.'); | ||
} | ||
const scanAnalytics = { | ||
score: data.positives || 0, | ||
totalScans: data.total || 0, | ||
scanResults: data.scans || {} | ||
// You can extract and process more data here as needed | ||
}; | ||
callback(scanAnalytics); | ||
}) | ||
.catch(error => { | ||
callback({ error: error.message }); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "VirusTotal URL Scanner", | ||
"version": "1.0", | ||
"permissions": [ | ||
"https://www.virustotal.com/*", | ||
"activeTab" | ||
], | ||
"background": { | ||
"scripts": ["background.js"], | ||
"persistent": false | ||
}, | ||
"browser_action": { | ||
"default_popup": "popup.html", | ||
"default_icon": { | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>VirusTotal URL Scanner</title> | ||
<link rel="stylesheet" href="style.css"> | ||
<script defer src="popup.js"></script> | ||
<style> | ||
body { | ||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; | ||
background-color: #f9f9f9; | ||
margin: 0; | ||
padding: 20px; | ||
text-align: center; | ||
} | ||
|
||
h1 { | ||
color: #333; | ||
margin-bottom: 20px; | ||
} | ||
|
||
label { | ||
font-size: 16px; | ||
display: block; | ||
margin-top: 15px; | ||
color: #555; | ||
} | ||
|
||
input { | ||
width: 100%; | ||
padding: 10px; | ||
margin-top: 8px; | ||
box-sizing: border-box; | ||
font-size: 16px; | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
} | ||
|
||
button { | ||
width: 100%; | ||
padding: 12px; | ||
margin-top: 20px; | ||
background-color: #4CAF50; | ||
color: white; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
font-size: 18px; | ||
} | ||
|
||
button:hover { | ||
background-color: #45a049; | ||
} | ||
|
||
#result { | ||
margin-top: 30px; | ||
color: #333; | ||
font-size: 18px; | ||
} | ||
|
||
.error { | ||
color: #d9534f; | ||
font-size: 16px; | ||
margin-top: 10px; | ||
} | ||
</style> | ||
</head> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>VirusTotal URL Scanner</h1> | ||
<div class="input-container"> | ||
<input type="text" id="urlInput" placeholder="Enter URL"> | ||
<button id="scanButton">Scan</button> | ||
</div> | ||
<div id="scanResult"></div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
document.addEventListener('DOMContentLoaded', function () { | ||
const scanButton = document.getElementById('scanButton'); | ||
const urlInput = document.getElementById('urlInput'); | ||
const scanResult = document.getElementById('scanResult'); | ||
|
||
scanButton.addEventListener('click', function () { | ||
const url = urlInput.value.trim(); | ||
if (url !== '') { | ||
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) { | ||
const activeTab = tabs[0]; | ||
chrome.runtime.getBackgroundPage(function (backgroundPage) { | ||
backgroundPage.scanURLWithVirusTotal(url, activeTab.id, function (result) { | ||
scanResult.innerText = JSON.stringify(result, null, 2); | ||
}); | ||
}); | ||
}); | ||
} else { | ||
scanResult.innerText = 'Please enter a URL.'; | ||
} | ||
}); | ||
}); |