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 :: javascript eliminar saltos de linea textarea 
Javascript :: ilan mask 
Javascript :: scrollbar position 
Javascript :: js module pattern 
Javascript :: assign values to array in javascript 
Javascript :: white with opacity rgba to hex 
Javascript :: create file node 
Javascript :: input type for mobile number in react js 
Javascript :: reference data types in javascript 
Javascript :: javascript merge multidimensional array 
Javascript :: twitter javascript api 
Javascript :: how to get length in js without using .length method 
Javascript :: discord.js command cooldown 
Javascript :: how to add function in javascript 
Javascript :: initiate node js app 
Javascript :: javascript array methods cheat sheet 
Javascript :: insertar al inicio de un array javascript 
Javascript :: how to remove the elements from array and how to replace a new element in javascript 
Javascript :: app.js not found in laravel 8 
Javascript :: dynamodb async await 
Javascript :: javascript Passing Function Value as Default Value 
Javascript :: combine all ts files into one js 
Javascript :: url 
Javascript :: 188.4 - 93.1 
Python :: epa meaning 
Python :: uuid regex 
Python :: error tokenizing data. c error 
Python :: conda requests 
Python :: python sleep random 
Python :: how to get micro symbol in python 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =