これは初めてfirefoxアドオンをビルドするのを初めて知りました。開いているすべてのタブをウィンドウに保存したいのですが、そのためにはsdk/tabsが必要です。私はタブ=は( "SDK /タブ")の行を必要とVARに達すると、私は参照エラーを取得FireFox webextensionでsdk/tabsを使用しているときのReferenceError
/*
Given the name of a beast, get the URL to the corresponding image.
*/
debugger;
var tabs = require("sdk/tabs");
function beastNameToURL(beastName) {
switch (beastName) {
case "Save Session":
debugger;
for (let tab of tabs)
console.log(tab.url);
return;
case "Load Session":
debugger;
return chrome.extension.getURL("beasts/snake.jpg");
case "Turtle":
return chrome.extension.getURL("beasts/turtle.jpg");
}
}
/*
Listen for clicks in the popup.
If the click is not on one of the beasts, return early.
Otherwise, the text content of the node is the name of the beast we want.
Inject the "beastify.js" content script in the active tab.
Then get the active tab and send "beastify.js" a message
containing the URL to the chosen beast's image.
*/
document.addEventListener("click", function(e) {
if (!e.target.classList.contains("btn")) {
return;
}
var chosenBeast = e.target.textContent;
var chosenBeastURL = beastNameToURL(chosenBeast);
chrome.tabs.executeScript(null, {
file: "/content_scripts/beastify.js"
});
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {beastURL: chosenBeastURL});
});
});
:
のGithub:https://github.com/sagar-shah/Session-manifest
親切に私はどのように私はこのエラーを解決します知っています。私が完全に失われているアドオンでこれは私の初めてのことです。
ありがとうございます。
更新: jsファイルでグローバルに宣言しようとしました。今私はタブの未定義のエラーを取得しています。
Update2: @matagusが指摘しているように、sdkとwebextensionsを使って開発をミックスしていました。私はwebextensionsを使って開発に行くことにしました。新しいリポジトリへのリンクが更新されました。
「main」ですか?「manifest.json」、「correct?すべての私のアドオンで 'index.js'に設定されています –
@FastSnailわかりません。チュートリアルではメインファイルはindex.jsで与えられていますが、ボタンをクリックするとポップアップを開き、ボタンをクリックするとjsファイルは実行しません。マニフェストにはポップアップファイルの詳細が含まれているので、私はmanifest.jsonをmainとして追加すると考えました。 – Posiedon
私は昨日それをうまく使った。それをグローバルに宣言しよう - https://github.com/Noitidart/jpmOAuth/blob/master/index.js - あなたは 'jpm run'または' jpm xpi'を使っていますか?あなたは 'cfx'の権利をしていないという意味ですか? 'cfx'は廃止されました。 – Noitidart