Created
June 24, 2024 11:28
-
-
Save gadgetmies/6166f4664d34fd44984aa4598cc8ff04 to your computer and use it in GitHub Desktop.
Search on Vivino Chrome context menu action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add a "Search on Vivino" context menu action to Google Chrome: | |
Create a folder with the following files and their contents: | |
event.js: | |
const menuItem = { | |
"id": "searchVivino", | |
"title": "Search on Vivino", | |
"contexts": ["selection"] | |
}; | |
chrome.contextMenus.create(menuItem); | |
chrome.contextMenus.onClicked.addListener(function (clickData) { | |
if(clickData.menuItemId == "searchVivino" && clickData.selectionText) { | |
chrome.tabs.create({ url: 'https://www.vivino.com/search/wines?q='+encodeURIComponent(clickData.selectionText) }); | |
} | |
}); | |
manifest.json: | |
{ | |
"manifest_version" : 2, | |
"name": "Search on Vivino", | |
"description": "Find wine ratings fast by searching selected text on Vivino", | |
"version": "1.0", | |
"background" : { | |
"scripts" : ["event.js"], | |
"persistent" : false | |
}, | |
"permissions" : [ | |
"contextMenus", | |
"tabs" | |
] | |
} | |
Drag the folder into Chrome Manage Extensions view to install the extension. After this selecting text and clicking the right | |
mouse button should display a "Search on Vivino" action in the context menu. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment