How to add "open link in app mode" to context menu in chrome?

Application mode: chrome window without navigation bar (address + tabs). Run this in terminal

google-chrome --app=http://stackoverflow.com/

      

I want to open a website in app mode directly from chrome. Is there an extension that adds such an option? If not, how do you write a small extension that does exactly that? I have never written a chrome extension, but I have some experience with html and javascript. Thanks to

Edit: main problem: chrome.windows.create doesn't have an "app" option for CreateType . I don't think we can do anything.

+3


source to share


1 answer


There is a way to use the chrome.management

API
.

chrome.management.generateAppForLink("http://stackoverflow.com/", "Stack Overflow", function(info) {
  chrome.management.setLaunchType(info.id, "OPEN_AS_WINDOW", function() {
    chrome.management.launchApp(info.id);
  })
});

      

Please note that the above code requires a user gesture (which is undocumented). See Calling foractiveTab

examples . Activating the context menu should be sufficient as a gesture.



However, this will create the app in the app launcher forever. On the other hand, it will not create duplicates for the same URL / header.

You can call chrome.management.uninstall(id)

, but this will require confirmation from the user.

+1


source







All Articles