所以我需要在我正在研究的Firefox插件中检查一些结果,但是console.log()不起作用.我试过简单地把它放在console.log("Hello World");main.js文件中并加载它,但是它没有记录任何东西.
我有这个.tsx文件
import React, { Component } from 'react';
export class SidebarItem extends Component {
constructor (props) {
super(props);
}
render () {
return (<li>{this.props.children}</li>);
}
}
Run Code Online (Sandbox Code Playgroud)
但是,TypeScript会抛出此错误:
error TS2339: Property 'props' does not exist on type 'SidebarItem'.
所以我一直在喋喋不休地谈论使用MutationObserver并且我没有取得任何进展.我在W3C网站和MDN上看过它.在MDN中阅读时,一切都有意义,直到这个例子.
// select the target node
var target = document.querySelector('#some-id');
// create an observer instance
var observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
console.log(mutation.type);
});
});
// configuration of the observer:
var config = { attributes: true, childList: true, characterData: true };
// pass in the target node, as well as the observer options
observer.observe(target, config);
// later, you can stop observing
observer.disconnect();
Run Code Online (Sandbox Code Playgroud)
我最麻烦的部分是创建观察者实例,不确定属于那里的语法.同样在控制台中我得到了一个"TypeError:Value没有实现接口Node".无论我看过哪些例子并尝试使用过; 用所需的jQuery选择器替换示例中的选择器(非jQ选择器也返回了同样的问题).
所以,我已经查看了WebExtensions API,但是我无法弄清楚如何打开与about:addons选项分开的HTML页面.在Add-on SDK中,您可以拥有resource://ext-id-/path/to/file.html.我已经尝试过访问目录Web并将HTML文件放在那里,但这似乎不起作用.
有谁知道如何在WebExtensions自带的选项卡中打开选项HTML文件?
javascript firefox firefox-addon firefox-addon-webextensions
所以我找不到任何谈论使用chrome.*或浏览器.*具体.在某些WebExtension示例中,它使用浏览器.*(browser.runtime.getManifest();)
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/getManifest,而在其他示例中,它使用chrome.*(chrome.notifications.create),https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/notifications.
我不完全确定有什么区别.是上下文吗?chrome.*和browser.*都可以在我的内容脚本和Firefox的后台脚本中找到.我也查看了IE文档,他们使用浏览器.*(在他们的文档中没有看到chrome.*)
我想知道它们之间有什么区别,Chrome扩展程序只使用chrome.*还是有浏览器.*(IE只有浏览器.*)?
google-chrome-extension firefox-addon-webextensions microsoft-edge-extension