-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
70 lines (62 loc) · 1.53 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// CloudShark Chrome Extension
// Developed by QA Cafe, 2017
// CloudShark Context Menu Creation
var buttons = {
mainButton: chrome.contextMenus.create({
title: "CloudShark",
contexts: ["all"],
enabled: false,
})
}
var goToButton = {
contexts:["all"],
parentId: buttons["mainButton"],
onclick: goToResponse,
enabled: false,
}
var analysisTools = {
ladder: "Ladder Diagram",
endpoints: "Endpoints",
conversations: "Conversations",
protocol_stats: "Protocol Hierarchy",
dns: "DNS Activity",
voip_calls: "VoIP Calls",
rtp_streams: "RTP Streams",
http_req: "HTTP Analysis",
http_objects: "HTTP Objects",
wlan_stats: "Wireless Networks",
threats_vectors: "Threat Assessment",
}
for (tool in analysisTools) {
var toolButton = {
title: analysisTools[tool],
id: "goToAnalysis/" + tool,
}
buttons[tool] = chrome.contextMenus.create(Object.assign(toolButton, goToButton));
}
// Go to analyis tool for capture
function goToResponse(info, tab) {
chrome.tabs.sendMessage(tab.id, info.menuItemId, function(response) {
chrome.tabs.update({
url: response
});
});
}
function disableButtons() {
for (b in buttons) {
chrome.contextMenus.update(buttons[b], { enabled: false, });
}
}
function enableButtons() {
for (b in buttons) {
chrome.contextMenus.update(buttons[b], { enabled: true, });
}
}
// Listen for message from content script
chrome.runtime.onMessage.addListener(function(message) {
if(message == "enable") {
enableButtons();
} else {
disableButtons();
}
});