Simple Chrome extension: Open image in CMS using file name in url

In my strides to make work more efficient for my colleagues I’m trying to make an extension that enables editors to open images directly from front end, a task our CMS can’t do.

The idea: When editors see an image they need to edit, they right-click and chose “Open in CMS”. The extension picks up the filename (including file extension) and opens a new url in our CMS.

Example:
Front end image url is http://www.justsomeurl.com/something/product.jpg

Image in the CSM can be accessed using search so that https://cms.justsomeurl.com/admin/appsomething/search:product.jpg

As a start I have tweaked an extension for Google Image search using this code:

function getClickHandler() {
  return function(info, tab) {

    var url = 'https://cms.justsomeurl.com/admin/appsomething/search:' + info.srcUrl;

    chrome.windows.create({ url: url, width: 1024, height: 870 });
  };
}

/**
 * Context menu.
 */
chrome.contextMenus.create({
  "title" : "Find image in CMS",
  "type" : "normal",
  "contexts" : ["image"],
  "onclick" : getClickHandler()
});

This of course sends the full url into the CMS search so it doesn’t work. I have tried to combine it with another script I found:

var url = window.location.pathname;
var filename = url.substring(url.lastIndexOf('/')+1);
alert(filename);

But since I basically have no idea what I’m doing it doesn’t work. Any help is greatly appreciated! Thanks!