我目前正在开发一个chrome扩展程序,源代码是。目标是将自定义Javascript注入到网页中。
目前,我将每个自定义Javascript注入存储在localStorage中,并从内容启动调用它们。我让document_start.的run_at
我使用它,从后台脚本获得存储的注入:
chrome.extension.sendMessage({method:"get_injects"},function(injects){
for(index in injects){
if(/^items\./.test(index)){
it
我想在我的chrome扩展中使用TinyMCE,但它不起作用,因为它试图从访问的网页()加载所有的.js文件,而不是从扩展的路径加载,路径类似于: chrome-extension://opioichmojlbogmkmoobbhckcaachnof/.我尝试添加document_base_url参数,但它不起作用。在Chrome扩展中加载TinyMCE作为内容脚本的正确方法是什么?
我们还试图修改tiny_mce.js,此时从扩展加载了.js文件,但我们得到了另一条错误消息:"tinymce is not defined“。
提前谢谢。
在我的chrome扩展中,我有一个后台脚本,它将获取使用XMLHttpRequest需要的一些数据。
// note that this code is in the global scope i.e. outside of any function
// also note that I got this code from the page talking about XMLHttpRequest
var myData = [];
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = handleStateChange;
xhr
我是新的,但我试图创建一个铬的扩展,以操纵在网页上的王国。目前,我有两个按钮,每个按钮将执行不同的任务。下面的内容有意义吗?另外,如果我有多个内容脚本,如何将它们添加到manifest.json中?
popup.js:
function injectTheScript() {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
// query the active tab, which will be only one tab
//and inject
我在Google chrome中创建了一个简单的扩展,下面是我的manifast.json
{
"name":"Hello World",
"version":"1.0",
"manifest_version":2,
"description":"The first extension that I made.",
"browser_action":{
"default_icon":"ic
简单地说,我的问题是:gtag.js操作的gtag.js对象和我的react上下文中可用的window对象( content.js上下文)是不同的对象,所以我不能从我的react代码中编写事件--这意味着我不能在扩展中使用分析。
更多的deets:
在react中,<script>标记不能直接为加载。因此,我已经更改了文档实现:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?i
我正在写一个扩展,它有选项,让用户决定他们想让扩展在哪个网站上运行。
假设用户在选项中有此站点
site action
stackoverflow.com/* change background css to blue
google.com/* change background css to green
我将这些字符串存储在选项中。当content_script运行时,我应该从选项中检索这些字符串,循环遍历每个字符串,用一个urlParser解析为各个部分,将每个部分转换为正则表达式(转义
对于Chrome扩展,我有一个非常简单的背景页面:
chrome.runtime.onInstalled.addListener((reason) => {
console.log(reason);
});
当加载我的扩展时,后台页面将运行:
该扩展还有一个弹出窗口,运行,使用:
const serviceWorkerWindow = await chrome.runtime.getBackgroundPage();
但以下几个方面都失败了:
Uncaught (in promise) Error: You do not have a background page.
我如何使