Open a new tab with xpath as search query

I am writing a chrome extension wich adds a context menu that when clicked opens a new google maps tab with a xpath value as search query.




/* Create a context-menu */
id: "GoogleMaps",   // <-- mandatory with event-pages
title: "Open On Google Maps",
contexts: ["all"]

/* Register a listener for the `onClicked` event */
chrome.contextMenus.onClicked.addListener(function(info, tab) {
if (tab) {
    /* Inject the code into the current tab */
    /* chrome.tabs.executeScript(, { code: code }); */
    chrome.tabs.executeScript(, {file: "content_script.js"});

content_script.js""+document.evaluate('//*[@id="component-1028"]/b', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerHTML;, '_blank');

But the content script doesn't seem to work with the document.evaluate added. But it works fine with something like this:""+, '_blank');

is it possible to add xpath value as a search query?


Google chrome extension to get google MAP contents like route information

how ro create Google chrome extension to get google MAP contents like route information, direction, source, destination from opened google map?

Refused to load the script of Google Maps library inside Chrome extension as external resources due to content security policy

I’m trying to build a Chrome extension that shows simple map. I’ve tried to load the Google Maps API using the attached code inside the content script:

var g = document.createElement('script');
g.src = "";
(document.head || document.documentElement).appendChild(g);

And of course, I’ve changed the content_security_policy to be like this:
"content_security_policy": "script-src 'self'; object-src 'self'"

But I still couldn’t make it work, I still get error message inside the Chrome console:

Refused to load the script
because it violates the following Content Security Policy directive:
“script-src ‘self’ ‘unsafe-inline’ ‘unsafe-eval’

A lot of questions here I’ve seen, but nothing works for me!