Skip to content

Commit b321ac1

Browse files
committed
Add handling for searching via context menu
1 parent 0c3de2e commit b321ac1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
'use strict';
3+
4+
chrome.runtime.onInstalled.addListener(function() {
5+
chrome.contextMenus.create({
6+
id: "stack_overflow_search_context_id",
7+
title: "Search in StackOverflow",
8+
type: 'normal',
9+
contexts: ['selection'],
10+
});
11+
});
12+
13+
chrome.contextMenus.onClicked.addListener(function(item, tab) {
14+
let searchUrl = "https://www.stackoverflow.com/search?q="+item.selectionText;
15+
chrome.tabs.create({url: searchUrl, index: tab.index + 1});
16+
});

0 commit comments

Comments
 (0)