firefox-addon-sdk

How do I prevent Firefox SDK content scripts from loading multiple times?

元气小坏坏 提交于 2020-01-14 03:30:13
问题 How do I prevent Firefox SDK content scripts from loading multiple times? The docs and a bug report I found suggest the contentScriptWhen property should limit the number of times my content scripts are executed, yet I see them running anywhere from twice to 15 times in a page load. Here's what's in my main.js: var data = require("sdk/self").data; var tabs = require('sdk/tabs'); var pageMod = require('sdk/page-mod'); pageMod.PageMod({ include: ['*'], contentScriptWhen: "ready",

When opening a new tab with a new tab page replacement add-on, how to keep the address bar clear?

寵の児 提交于 2020-01-13 03:41:50
问题 I'm developing a new tab page replacement add-on for Firefox. After it's installed, when I click the new tab icon to open a new tab, the new tab opens fine, but the address bar shows a messy URL: resource://firefox_p-at-getblog-dot-com/getblog_buttons_page/data/newtab.html How do I make the address bar empty? 回答1: There are only a few pages that will have "blank" uris in the URI bar. Now, you have a couple of options: Overlay/inject into browser.xul and just add your add-on URI to

Firefox SDK Add-on with a sidebar on both the right and left at the same time

跟風遠走 提交于 2020-01-10 05:45:15
问题 I'm programming a Firefox Add-on SDK based extension. I need to use both a left and a right-side sidebar, at the same time . By default, I can display one on the left side. I've already read about changing between having the ui/sidebar on the left and the right by using the CSS: @namespace url(http://www.mozilla.org/keymaster/gat...re.is.only.xul); hbox#browser { direction: rtl !important; } hbox#browser > vbox { direction: ltr !important; } But, that seems to be something of the old-school,

Detect tab URL change inside a Firefox add-on

我是研究僧i 提交于 2020-01-10 03:49:06
问题 I have an extension, functional on Chrome, that monitors the active Tab for URL changes. Specifically, I need to detect when the URL changes, but there is no new page load or navigation. Some sites do this (e.g. when you click to view another video on YouTube). On Chrome, I accomplished this with: chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { if (changeInfo && changeInfo.status == "complete") { //do stuff here } }); How do I detect such changes in a Firefox add-on? I've

Save website image using a Firefox Addon (SDK)

自闭症网瘾萝莉.ら 提交于 2020-01-07 02:33:18
问题 I am able to grab the URL of an image on a website, but I want to download the image to the local drive. I actually want the standard download prompt. What is the best way to do this using Firefox Addon SDK (using Javascript)? 回答1: So using some code lifted from Firefox's nsIWebBrowserPersist docs, I cobbled this together. I don't understand some of the scope issues involved, and this does not prompt the user for where or how to save. For my purposes, it works, but I would like a better

Firefox addon SDK error: Unable to Remove from Inner-Toolbar

六眼飞鱼酱① 提交于 2020-01-06 15:05:49
问题 After hours and hours trying to get things working, I have this error in my console: [CustomizableUI] Widget action-button--myAddonID-misspelutton not found, unable to remove from inner-toolbar-myAddonID-the-title-of-my-addon1 CustomizableUI.jsm:171 So, the addon's widget id is misspelled somehow and stuck somewhere. The term does not appear in any of my code. Details: I originally built this addon using XUL overlays, and am rebuilding it with the Firefox AddOn SDK. I think (but I'm not sure)

When i add contentscript using page-mod in firefox extension. The content script functions are executed thrice

守給你的承諾、 提交于 2020-01-05 12:11:42
问题 I am unable to understand . Why my functions are executed thrice after addition in the firefox extension using "page-mod" . This is my code : [ main.js ] var pageModOptions = { include: ["http://xyz.com/*"], attachTo: ["top", "frame", "existing"], contentScriptWhen: "end", onAttach: function(worker){ worker.port.on("Done", function(elementContent) { console.log("emitted by tarun :" + elementContent); worker.port.emit("start", htmlfilePath); }); }, }; pageModOptions.contentScriptFile = [data

Fast way to redirect tab when new page is loading

白昼怎懂夜的黑 提交于 2020-01-05 10:24:34
问题 I'm trying to redirect a tab to a new page when the URL matches my pattern before it's done loading. The method I came up with does the redirection after a good part of the page is done loading yet. var tabs = require("sdk/tabs"); var tab_utils = require("sdk/tabs/utils"); function logShow(tab) { console.log(tab.url + " is loaded; " + pattern.test(tab.url)); if (pattern.test(tab.url)) { var lowLevelTab = viewFor(tab); console.log(tab_utils.setTabURL (lowLevelTab, newURL(tab.url))); // also

firefox add-on sdk: make panel to stay visible

喜你入骨 提交于 2020-01-05 04:04:22
问题 I'm trying to build a Firefox add-on based on their SDK and I wanna use panel for this. The panel is connected to a widget, so every time I click on the widget icon the panel shows up. My problem is that I want the panel to stay visible even if I click on an area outside the panel and to be able to close only based on a certain situations. Can this be achieved, or the panel API doesn't support this? Thanks 回答1: It can't be achieved through the SDK API. However, you could actually "hack" the

How can I access firefox extension resources

最后都变了- 提交于 2020-01-05 01:24:06
问题 How can I access firefox extension data from javascript code injected directly to the page? I´m looking for something similar to web_accessible_resources key in manifest.json for chrome extensions. I´m building bootstraped (restarless) extension with addon-sdk. When I´m injecting individual scripts into the page from content script it works fine, but when I want to access the resource from page it won´t let me - error message is something like Access to restricted URI denied. . I can also