如何在Chrome中右键单击菜单中添加“在应用模式下打开链接”?

时间:2022-08-26 21:32:27

app mode: chrome window without navigation panel(address+tab bars). Run this in terminal

应用模式:没有导航面板的chrome窗口(地址+标签栏)。在终端中运行此命令

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

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

我想直接从chrome打开一个应用模式的网站。是否有添加此选项的扩展名?如果不是,我该如何编写一个小扩展程序呢?我从来没有写过chrome扩展,但我有一些html和javascript的经验。谢谢

Edit: Main issue is chrome.windows.create has no "app" option for CreateType. I guess we can't do anything about it.

编辑:主要问题是chrome.windows.create没有CreateType的“app”选项。我想我们无能为力。

1 个解决方案

#1


1  

There is a way using chrome.management API.

有一种方法可以使用chrome.management API。

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

Note that the above code requires a user gesture (which is undocumented). For examples, see Invoking activeTab. Activating a context menu should be sufficient as a gesture.

请注意,上面的代码需要用户手势(未记录)。有关示例,请参阅调用activeTab。激活上下文菜单应该足够作为手势。

However, this will create an app in the app launcher permanently. On the plus side, it will not create duplicates for the same URL/Title.

但是,这将在应用启动器中永久创建一个应用。从好的方面来说,它不会为同一个URL / Title创建重复项。

You can call chrome.management.uninstall(id), but it will require a confirmation from the user.

您可以调用chrome.management.uninstall(id),但需要用户确认。

#1


1  

There is a way using chrome.management API.

有一种方法可以使用chrome.management API。

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

Note that the above code requires a user gesture (which is undocumented). For examples, see Invoking activeTab. Activating a context menu should be sufficient as a gesture.

请注意,上面的代码需要用户手势(未记录)。有关示例,请参阅调用activeTab。激活上下文菜单应该足够作为手势。

However, this will create an app in the app launcher permanently. On the plus side, it will not create duplicates for the same URL/Title.

但是,这将在应用启动器中永久创建一个应用。从好的方面来说,它不会为同一个URL / Title创建重复项。

You can call chrome.management.uninstall(id), but it will require a confirmation from the user.

您可以调用chrome.management.uninstall(id),但需要用户确认。