Google Chrome 扩展:如何在以编程方式注入的内容脚本中包含 jQuery? [英] Google Chrome Extensions: How to include jQuery in programmatically injected content script?

查看:24
本文介绍了Google Chrome 扩展:如何在以编程方式注入的内容脚本中包含 jQuery?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户点击浏览器操作按钮时,我从后台页面注入我的内容脚本,如下所示:

I'm injecting my content script from the background page when the user clicks the browser action button, like so:

chrome.browserAction.onClicked.addListener(function (tab) {
    chrome.tabs.executeScript(null, { file: "content.js" });
});

那么如何从我的 content.js 内部访问 jQuery?我看不到同时注入的方法.

So how can I access jQuery from inside my content.js? I don't see a way to inject that simultaneously.

推荐答案

关于:

chrome.tabs.executeScript(null, { file: "jquery.js" }, function() {
    chrome.tabs.executeScript(null, { file: "content.js" });
});

您可以从这里下载jquery.js":http://jquery.com/download/

You can download "jquery.js" from here: http://jquery.com/download/

这篇关于Google Chrome 扩展:如何在以编程方式注入的内容脚本中包含 jQuery?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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