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 :: before in javascript 
Javascript :: send data with emit angular 
Javascript :: how to add key value pair in object 
Javascript :: js example 
Javascript :: react switch case 
Javascript :: react filter array 
Javascript :: updatedAt mongoose stop 
Javascript :: cy.contains 
Javascript :: style.backgroundcolor 
Javascript :: moment date format 
Javascript :: electron . not working 
Javascript :: what are devtools 
Javascript :: mapStateProps 
Javascript :: access an object js 
Javascript :: is value in list javascript 
Javascript :: slimscroll javascript 
Javascript :: what hostings can run react js 
Javascript :: inline null check javascript 
Javascript :: how to add class in javascript dynamically 
Javascript :: hide show object in react 
Javascript :: javascript entries() method 
Javascript :: how to decode jwt token in angular 
Javascript :: convert text to qr code in angular 
Javascript :: react native spinkit 
Javascript :: js regexp match 
Javascript :: local forage 
Javascript :: promise in es6 
Javascript :: A better way to concatenate arrays 
Javascript :: nextjs starter template with auth 
Javascript :: click tester 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =