Skip to content

Commit

Permalink
Merge pull request #6 from 2000me/window-or-tab
Browse files Browse the repository at this point in the history
Tested with Firefox Developer Edition 73.0b3
  • Loading branch information
2000me committed Jan 12, 2020
2 parents c990739 + fb04e5f commit 08a8ce6
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 13 deletions.
18 changes: 18 additions & 0 deletions AMO/description.html
@@ -0,0 +1,18 @@
This add-on allows to scan a given URL with multiple virus scanners.
VirusTotal provides this service.
See <a href="https://www.virustotal.com/">https://www.virustotal.com/</a>.
Right click on the URL.
Select VirusTotal Scan.
Observe the scan results.
By default the scan results are displayed in a new window.
A new tab display configuration option is available.

This add-on requests the following permissions.
<ul>
<li>Access your data for virustotal.com in order to perform the scan.</li>
<li>Display notifications to you in order to display progress or errors.</li>
</ul>
For issues such as bugs, feature requests, questions, problem support, or suggestions use <a href="https://github.com/2000me/vtscan/issues">https://github.com/2000me/vtscan/issues</a>.

Contributions such as localizations are welcome as pull requests.
<a href="https://github.com/2000me/vtscan/pulls">https://github.com/2000me/vtscan/pulls</a>.
4 changes: 2 additions & 2 deletions README.md
@@ -1,6 +1,6 @@
# vtscan
Add-on: Scan URL with VirusTotal

This add-on allows to scan a given URL with multiple virus scanners. VirusTotal provides this service. See https://www.virustotal.com/. Right click on the URL. Select VirusTotal Scan. Observe the scan results in a new window.
This add-on allows to scan a given URL with multiple virus scanners. VirusTotal provides this service. See https://www.virustotal.com/. Right click on the URL. Select VirusTotal Scan. Observe the scan results. By default the scan results are displayed in a new window. A new tab display configuration option is available.

![Context menu](AMO/vtscan.png)
![Context menu](AMO/vtscan.png)
13 changes: 11 additions & 2 deletions _locales/en/messages.json
Expand Up @@ -6,17 +6,26 @@
"message": "Scan URL with VirusTotal"
},
"notifyQueuedAndPolling": {
"message": "VirusTotal Scan queued.\nPolling every $POLL_INTERVAL_SECONDS$ seconds for the results...",
"message": "Scan queued. Polling every $POLL_INTERVAL_SECONDS$ seconds for the results.",
"placeholders": {
"POLL_INTERVAL_SECONDS": {
"content": "$1"
}
}
},
"notifyStillQueuedStoppedPolling": {
"message": "VirusTotal Scan still queued. Stopped polling for the results.\nPlease select VirusTotal Scan again in a minute or later."
"message": "Scan still queued. Stopped polling. Please rescan later."
},
"notifyUnexpectedResponse": {
"message": "Received unexpected response. Please retry."
},
"options_resultsDisplayLabel": {
"message": "Results display: "
},
"option_tab": {
"message": "new tab"
},
"option_window": {
"message": "new window"
}
}
4 changes: 2 additions & 2 deletions b.html
Expand Up @@ -2,6 +2,6 @@
<html lang="en">
<head>
<meta charset="utf-8">
<script type="module" src="b.js"></script>
<script type="module" src="js/b.js"></script>
</head>
</html>
</html>
15 changes: 11 additions & 4 deletions b.js → js/b.js
Expand Up @@ -65,13 +65,16 @@ function pollReport(responseJson, reportUrl, i) {
notifyUsingBasicNotification(
browser.i18n.getMessage('notifyStillQueuedStoppedPolling')
);
}
}
} else {
var id = responseJson.scan_id.substring(0, 64);
if (id.match(/^[0-9a-f]{64}$/)) {
browser.windows.create({
url: DETECTION_URL_PREFIX + id + DETECTION_URL_SUFFIX
});
var pUrl = DETECTION_URL_PREFIX + id + DETECTION_URL_SUFFIX
if (localStorage.getItem("TabOrWindow") == "w") {
browser.windows.create({url: pUrl});
} else {
browser.tabs.create({url: pUrl});
}
} else {
notifyUsingBasicNotification(
browser.i18n.getMessage('notifyUnexpectedResponse')
Expand Down Expand Up @@ -113,3 +116,7 @@ browser.contextMenus.onClicked.addListener((info, tab) => {
scan(SCAN_URL_PREFIX + info.linkUrl, REPORT_URL_PREFIX + info.linkUrl);
}
});

if (localStorage.getItem("TabOrWindow") == null) {
localStorage.setItem("TabOrWindow", "w");
};
14 changes: 14 additions & 0 deletions js/i18n.js
@@ -0,0 +1,14 @@
const translate = (function() {
const nodes = document.querySelectorAll("[data-i18n]");
nodes.forEach(
function(node) {
node.textContent = browser.i18n.getMessage(
node.getAttribute('data-i18n')
)
}
)
});

window.addEventListener('DOMContentLoaded', (event) => {
translate();
});
16 changes: 16 additions & 0 deletions js/options.js
@@ -0,0 +1,16 @@
if (localStorage.getItem("TabOrWindow") == null) {
localStorage.setItem("TabOrWindow", "w");
}

if (localStorage.getItem("TabOrWindow") == "w") {
document.getElementById("optionWindow").checked = true;
} else {
document.getElementById("optionTab").checked = true;
}

document.getElementById("optionTab").addEventListener("click", function(){
localStorage.setItem("TabOrWindow", "t");
});
document.getElementById("optionWindow").addEventListener("click", function(){
localStorage.setItem("TabOrWindow", "w");
});
10 changes: 7 additions & 3 deletions manifest.json
Expand Up @@ -11,10 +11,14 @@
},
"manifest_version": 2,
"name": "__MSG_extensionName__",
"options_ui": {
"page": "options.html",
"browser_style": true
},
"permissions": [
"contextMenus",
"notifications",
"https://www.virustotal.com/*"
],
"version": "0.6.0"
"https://www.virustotal.com/*"
],
"version": "0.6.1"
}
17 changes: 17 additions & 0 deletions options.html
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="js/i18n.js"></script>
</head>
<body>
<form>
<label data-i18n="options_resultsDisplayLabel"></label>
<input type="radio" name="resultsDisplayOption" id="optionTab">
<label data-i18n="option_tab"></label>
<input type="radio" name="resultsDisplayOption" id="optionWindow">
<label data-i18n="option_window"></label>
</form>
<script src="js/options.js"></script>
</body>
</html>

0 comments on commit 08a8ce6

Please sign in to comment.