-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
33 lines (30 loc) · 971 Bytes
/
background.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
chrome.runtime.onInstalled.addListener(() => {
chrome.contextMenus.create({
id: "textConverter",
title: "Obfuscate Text",
contexts: ["selection"]
});
const formats = [
"pigLatin", "leetSpeak", "reverse", "morseCode", "sarcasm",
"base64", "hexadecimal", "rot13", "atbash", "caesarCipher",
"base32", "binary", "urlEncode", "emojiSubstitution", "soundex",
"bracketed", "zAlgo", "vigenere", "asciiArt", "doublespeak",
"customSymbols", "numeralConversion", "textualEncoding"
];
formats.forEach(format => {
chrome.contextMenus.create({
id: format,
parentId: "textConverter",
title: `to ${format.charAt(0).toUpperCase() + format.slice(1)}`,
contexts: ["selection"]
});
});
});
chrome.contextMenus.onClicked.addListener((info, tab) => {
if (info.parentMenuItemId === "textConverter") {
chrome.tabs.sendMessage(tab.id, {
action: "convert",
format: info.menuItemId
});
}
});