如何将我的应用中的url参数传递给Chrome扩展? [英] How can I pass an url parameter from my app to the Chrome extension?

查看:143
本文介绍了如何将我的应用中的url参数传递给Chrome扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Google App Engine应用程序中,我想传递此用户信息。

  user = users.get_current_user()$ b $当用户点击应用程序中的按钮时,您可以在网址参数中的Chrome扩展程序中使用b  



我怎么做到这一点? google.com/chrome/extensions/xhr.htmlrel =nofollow> Cross-Origin HMLHttpRequest ,但这似乎是将信息发送给应用程序而不是接收。

这是关于这个问题的其他问题的后续。

解决方案

您无法通过像这样的URL参数将信息传递到后台,但是您有几个选项。

可能最简单的方法是将扩展插入内容脚本添加到您的应用中。由于内容脚本在您的Web应用程序的上下文中运行,因此它可以访问用户详细信息以及您可能要传递的任何其他信息。

然后,通过消息传递(请参阅 http://code.google.com/chrome/extensions/messaging.html),您可以使用您要发送的信息向后台页面发送消息。


In my Google App Engine app I want to pass this user information

    user = users.get_current_user()

to the Chrome extension in a url paramenter when the user clicks a button in the app.

How can I do this?

I read about Cross-Origin HMLHttpRequest but that seems about sending info to the app not about receiving.

This is a follow up to my other questions on this subject.

解决方案

You can't pass information to the background via a URL parameter like this, but you've got a couple of options.

Probably the easiest way to do this would be to have the extension inject a content script in to your app. Since the content script runs in the context your your web app, it has access to the user details and any other information you might want to pass.

Then, via Message Passing (see http://code.google.com/chrome/extensions/messaging.html), you could send a message to the background page with the information that you're trying to send.

这篇关于如何将我的应用中的url参数传递给Chrome扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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