chrome/chromium 扩展:通过上下文菜单运行可执行文件/脚本 [英] chrome/chromium extension: run a executable/script via the context menu

查看:27
本文介绍了chrome/chromium 扩展:通过上下文菜单运行可执行文件/脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个供个人使用的小型 chrome 扩展程序,我想通过上下文菜单运行可执行文件并将某些信息作为参数传递给所述可执行文件.

实现这一目标的最简单和/或最干净的方法是什么?对我来说,由于 chrome 的沙盒,这似乎是不可能的.

解决方案

这可以通过 通过NPAPI 插件.

<块引用>

在 NPAPI 插件中运行的代码具有当前用户,并且不会被沙盒或屏蔽恶意输入谷歌浏览器以任何方式.你应该特别小心,当处理来自不受信任来源的输入,例如在使用内容脚本或 XMLHttpRequest.

但是,我也应该包括他们的警告.

<块引用>

警告

NPAPI 正在逐步淘汰. 考虑使用替代品.

NPAPI 是一把非常大的锤子,只有在没有其他人的情况下才应该使用方法会奏效.

通过 从 Google Chrome 扩展程序启动外部应用程序?

NPAPI 的替代方案

  1. <块引用>

    NPAPI 有多种替代方案.在标准网络的情况下技术还不够,开发人员和管理员可以使用 NaCl, 应用程序, 原生消息API旧版浏览器支持从 NPAPI 过渡.展望未来,我们的目标是发展基于标准的网络平台,涵盖曾经由NPAPI.

    通过 http://blog.chromium.org/2013/09/saying-goodbye-to-our-old-friend-npapi.html

  2. 另一种方法,这里建议,是使用 Java.

    <块引用>

    Java 小程序:http://docs.oracle.com/javase/tutorial/部署/小程序/

    实施政策:http://docs.oracle.com/javase/tutorial/security/userperm/policy.html

  3. 使用sendNativeMessage:

    <块引用>

    chrome.runtime.sendNativeMessage 可以使用发送一个向本机应用程序和 chrome.runtime.connectNative 发送消息允许更持久的连接.

    所以,你不能直接执行一个命令,但是你可以有一个原生的应用程序为您完成.

    您可以在文档中找到有关 本地消息传递的更多信息.

    通过https://stackoverflow.com/a/19917672/1085891

I'm writing a small chrome extension for personal use and I would like to run an executable via the context menu and pass certain information as arguments to said executable.

What the simplest and/or cleanest way to achieve this? To me it seems that it is impossible due to chrome's sandboxing.

解决方案

This can be accomplished via NPAPI Plugins.

Code running in an NPAPI plugin has the full permissions of the current user and is not sandboxed or shielded from malicious input by Google Chrome in any way. You should be especially cautious when processing input from untrusted sources, such as when working with content scripts or XMLHttpRequest.

However, I should also include their warning.

Warning

NPAPI is being phased out. Consider using alternatives.

NPAPI is a really big hammer that should only be used when no other approach will work.

via Start an external application from a Google Chrome Extension?

Alternatives to NPAPI

  1. There are several alternatives to NPAPI. In cases where standard web technologies are not yet sufficient, developers and administrators can use NaCl, Apps, Native Messaging API, and Legacy Browser Support to transition from NPAPI. Moving forward, our goal is to evolve the standards-based web platform to cover the use cases once served by NPAPI.

    via http://blog.chromium.org/2013/09/saying-goodbye-to-our-old-friend-npapi.html

  2. Another way, suggested here, is with Java.

    Java applets: http://docs.oracle.com/javase/tutorial/deployment/applet/

    Implementing Policy: http://docs.oracle.com/javase/tutorial/security/userperm/policy.html

  3. Use sendNativeMessage:

    There is chrome.runtime.sendNativeMessage which can be used to send a message to a native application and chrome.runtime.connectNative which allows for a more persistent connection.

    So, you can't directly execute a command, but you can have a native app do it for you.

    You can find more info on Native Messaging in the docs.

    via https://stackoverflow.com/a/19917672/1085891

这篇关于chrome/chromium 扩展:通过上下文菜单运行可执行文件/脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆