Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

chrome extension contextMenus

chrome.runtime.onInstalled.addListener(function() {
    chrome.contextMenus.create({
        "title": 'Search Google for "%s"',
        "contexts": ["selection"],
        "id": "myContextMenuId"
    });
});
    
chrome.contextMenus.onClicked.addListener(function(info, tab) {
    chrome.tabs.create({  
        url: "http://www.google.com/search?q=" + encodeURIComponent(info.selectionText)
    });
})
Comment

contextMenus chrome extensions

//Create the context menu
chrome.runtime.onInstalled.addListener(function() {
    chrome.contextMenus.create({
        "title": 'Search Google for "%s"',
        "contexts": ["selection"],
        "id": "myContextMenuId"
    });
});
    
//Onclick listener
chrome.contextMenus.onClicked.addListener(function(info, tab) {
    chrome.tabs.create({  
        url: "http://www.google.com/search?q=" + encodeURIComponent(info.selectionText)
    });
})
Comment

chrome.contextmenus

function getword(info,tab) {
  console.log("Word " + info.selectionText + " was clicked.");
  chrome.tabs.create({  
    url: "http://www.google.com/search?q=" + info.selectionText
  });
}
chrome.contextMenus.create({
  title: "Search: %s", 
  contexts:["selection"], 
  onclick: getword
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to use jquery plugins in angular 8 
Javascript :: node js simple server 
Javascript :: nodejs remove element from array 
Javascript :: react native refresh on pull down 
Javascript :: discord.js v12 how to set owner commands 
Javascript :: array.splice 
Javascript :: str into array 
Javascript :: install react hotjar 
Javascript :: how to coerce a string to number in javascript 
Javascript :: js text match 
Javascript :: generate new component angular 
Javascript :: vue file 
Javascript :: javascript stringify blob 
Javascript :: google places autocomplete react native 
Javascript :: connect to redux store outside component 
Javascript :: localstorage getitem 
Javascript :: convert c# to javascript online 
Javascript :: perfect scrollbar jquery 
Javascript :: javascript filter method arrow function 
Javascript :: detect localstorage limit 
Javascript :: Grunt--example gruntfile.js 
Javascript :: Limit number of selected chekboxes 
Javascript :: angularjs form validation on submit 
Javascript :: JavaScript Sorting Arrays 
Javascript :: delete request reaxt 
Javascript :: response intersepters for axios create 
Javascript :: react new project 
Javascript :: check cookies client side 
Javascript :: print stuff in console javascript 
Javascript :: difference between js and jsx 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =