I am working on a chrome extension that will count selected words.
manifest.json file
{
"manifest_version": 2,
"name": "Word Counter",
"description": "To count article words",
"version": "1.0.0",
"icons": {
"128": "icon_128.png"
},
"background": {
"scripts": [
"eventPage.js"
],
"persistent": false
},
"permissions": [
"activeTab",
"contextMenus"
]
}
eventPage.js file
let contextMenuItem = {
"id": "countWords",
"title": "count words",
"contexts": ["selection"]
}
chrome.contextMenus.create(contextMenuItem)
chrome.contextMenus.onClicked.addEventListener((selectedData) => {
if (selectedData.menuItemId == 'countWords' && selectedData) {
//What would be the logic
}
})
it will add an option "count words" on right click. Now I want when I click the count words option a modal appear on the middle of the screen that shows the number of words I have selected.
I can figure out the logic for counting words but don't know how to show the modal on click with some logics.