firefox-addon-sdk

Promise resolve not called because popup closes too fast

这一生的挚爱 提交于 2019-12-13 03:44:01
问题 I have the following piece of code: browser.windows.create({ url: urls }).then((newWindow) => { newWindow.tabs.slice(0, pins.length).map((tab, index) => { browser.tabs.update(tab.id, { pinned: true }) }) }) It works great when I prevent the popup from closing (via webdev tools) but in a regular use case, the resolve is not triggered. 回答1: I struggled with this same problem when I started working on my addon (In My Pocket for Firefox, you can have a look at the code on bitbucket if it can help

content script access to webpage js [duplicate]

拈花ヽ惹草 提交于 2019-12-13 03:42:36
问题 This question already has an answer here : How can my Add-on SDK content script interact with a website page script? (1 answer) Closed 5 years ago . I create a firefox addon with the online addon builder. How can one use an existing function on a webpage, from within the addon? This site doesn't belong to me, so I can't bind event listeners, in order to send an event to it from my addon. Update: Now I have this code but it doesn't work: main.js var widgets = require("widget"); var tabs =

Firefox SDK port sending functions

无人久伴 提交于 2019-12-13 02:18:28
问题 When I trying to send a function through port.emit it ends up null on the other side. If I change it to a simple string it works fine. Can you not send functions throw emit? self.port.emit("requestBackground", someFunction); 回答1: A quick look at the documentation for port.emit() indicates: It may be called with any number of parameters, but is most likely to be called with a name for the message and an optional payload. The payload can be any value that is serializable to JSON. Clicking on

Is there an API to control downloads in Firefox add-on SDK?

送分小仙女□ 提交于 2019-12-13 01:34:06
问题 In Firefox, is there an API equivalent to Google Chrome's chrome.downloads API? I need to control downloads with functions such as pause, resume, and cancel. In addition, I want to be able to remove the downloaded file. If there is no API in Firefox add-on SDK, is it possible to do the same things in another way? 回答1: The API's are (links to documentation on MDN): Downloads.jsm Download DownloadTarget PlacesUtils.There is good info at paa's answer to the question: API to modify Firefox

Firefox add-on script gets executed many times

Deadly 提交于 2019-12-13 01:27:43
问题 I want to create a simple add-on to edit an iframe at a certain page. I read the MDN add-on SDK tutorial, found a tutorial which explains how to interact with a page, here is the index.js : var pageMod = require("sdk/page-mod"); pageMod.PageMod({ include: "http://www.kongregate.com/games/tfender/contract-wars", contentScriptFile: "./main.js" }); Here is the data/main.js , the contentScriptFile: window.__cw_fullscreen_started = false; if (!__cw_fullscreen_started) { console.log('started!'); _

How to get the URL of clicked link?

大憨熊 提交于 2019-12-13 01:18:51
问题 I am trying to create an add-on through Mozilla Add-On Builder. What I need to know is how to get the URL of a left clicked link in the active tab through the add-on and open it in a new tab. I know this process involved adding an eventlistener through a page-mod and then using the tabs module, however I can't seem to get the syntax correct. Edit: (This is what I have so far) var Widget = require("widget").Widget; var tabs = require('tabs'); var pageMod = require("page-mod"); exports.main =

How to remove an event listener?

百般思念 提交于 2019-12-13 00:38:35
问题 I use the Mozilla's Add-on Builder. I am looking for a way to remove an event listener in a contentScript. I use the port way to communicate between add-on script code and the content script code. The problem is the callback on event "response" is called more than once. I want it to be called once and declared in the callback of the event show. Can someone help me with that? main.js code: var Panel = require("panel").Panel; var popup_panel = Panel({ width: 286, height: 340, contentURL:

firefox webextension alternative to addon clipboard sdk for copying images

笑着哭i 提交于 2019-12-13 00:02:39
问题 I am trying to develop a Firefox extension which involves copying an image to the clipboard. In the past, it appears that this was accomplished using the clipboard addon sdk. However, this is being deprecated so I need to find another way to copy an image to the clipboard. The docs mentioned using document.execCommand('copy') but I cant get that to work for copying images. From searching the web it seems that its normally not possible to copy an image to the clipboard in Javascript but I was

Firefox SDK: how “capture” users hotkey in preferences?

点点圈 提交于 2019-12-12 22:15:13
问题 In package.json I have: "preferences": [{ "name": "hotkeyPopup", "title": "Hotkey for translating selected text", "type": "string", "value": "alt-Y" }] And it looks like input type=text . How can I capture user's hotkey combination? This is not cool that user must type by hands words like alt or even worse accel . Official documentation about hotkeys say nothing about capturing in preferences. 回答1: In this snippet window can be a content window (tab/iframe/etc) or xul window (nsIDOMWindow)

Addon SDK way to make a dialog

拥有回忆 提交于 2019-12-12 20:28:29
问题 What is the proper way to use the SDK to make a dialog (which is not anchored to the add-on bar, etc. but shows centered on screen)? It doesn't seem like there is any API for this important capability. I do see windows/utils has open but I have two problems with that: The dialog opening seems to require "chrome" privs to get it to be centered on the screen (and I'd be expectant of add-on reviewers complaining of chrome privs, and even if not, I'd like to try to stick to the SDK way). While I