53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
// adapted from heavily from:
|
|
// https://medium.com/bugbountywriteup/sputnik-an-open-source-intelligence-browser-extension-da2f2c22c8ec
|
|
// https://github.com/mitchmoser/sputnik
|
|
|
|
browser.contextMenus.create({
|
|
id: "CVE Search",
|
|
title: "CVE Search",
|
|
contexts: ["selection"]
|
|
});
|
|
|
|
browser.contextMenus.create({
|
|
id: "NVD",
|
|
title: "NVD",
|
|
contexts: ["selection"],
|
|
parentId: "CVE Search",
|
|
icons: {
|
|
"48": "icons/nvd_48.png"
|
|
}
|
|
});
|
|
|
|
browser.contextMenus.create({
|
|
id: "MITRE",
|
|
title: "MITRE",
|
|
contexts: ["selection"],
|
|
parentId: "CVE Search",
|
|
icons: {
|
|
"48": "icons/mitre_48.png"
|
|
}
|
|
});
|
|
|
|
// create empty url variable
|
|
var url = ""
|
|
|
|
/*
|
|
* The click event listener:
|
|
* where we perform the approprate action
|
|
* given the ID of the menu item that was clicked
|
|
*/
|
|
|
|
browser.contextMenus.onClicked.addListener((info, tab) => {
|
|
// copy the selection to clipboard
|
|
navigator.clipboard.writeText(info.selectionText);
|
|
|
|
switch (info.menuItemId) {
|
|
case "NVD":
|
|
url = "https://nvd.nist.gov/vuln/detail/"+info.selectionText;
|
|
break;
|
|
case "MITRE":
|
|
url = "https://cve.mitre.org/cgi-bin/cvename.cgi?name="+info.selectionText;
|
|
break;
|
|
}
|
|
browser.tabs.create({url: url});
|
|
});
|