firefox-webextensions

firefox addon tabs.executeScript error on specific pages No window matching {“matchesHost”:[“<all_urls>”]}

人盡茶涼 提交于 2019-12-01 13:02:36
问题 I have a firefox webextension ported from chrome extension. The executeScript call fails on this site. https://addons.mozilla.org/en-US/firefox/ I tested with multiple pages on this site and all are giving the same error The bare-minimum code to reproduce this is popup.js document.addEventListener("DOMContentLoaded", function () { chrome.tabs.query({"active": true}, function(tabs) { chrome.tabs.executeScript(tabs[0].id, {"code": "console.log('Script executed in ' + document.location.href);"},

Firefox Extension - onPopupClose event?

给你一囗甜甜゛ 提交于 2019-12-01 10:47:10
I have popup in which I need to update the data inside it in reactively. What function or event is needed to track when a popup closes? Currently my code structure is as follows: let BG = browser.extension.getBackgroundPage(); let timer = BG.timer; function updatePageTime(secondsElapsed) { const content = document.getElementById("content"); content.innerHTML = "Current Time Spent: " + timer.getTimeElapsed(); } document.addEventListener("DOMContentLoaded", function () { timer.subscribe(updatePageTime); }); document.addEventListener("unload", function () { timer.unsubscribe(updatePageTime); });

Firefox Extension - onPopupClose event?

一曲冷凌霜 提交于 2019-12-01 07:29:58
问题 I have popup in which I need to update the data inside it in reactively. What function or event is needed to track when a popup closes? Currently my code structure is as follows: let BG = browser.extension.getBackgroundPage(); let timer = BG.timer; function updatePageTime(secondsElapsed) { const content = document.getElementById("content"); content.innerHTML = "Current Time Spent: " + timer.getTimeElapsed(); } document.addEventListener("DOMContentLoaded", function () { timer.subscribe

Web Extension : How do I use “browser_style = true”?

两盒软妹~` 提交于 2019-12-01 05:29:58
When writing a Firefox web extension it's possible to use a default css for browser or page actions so that they are styled like other browser UI components. It's done by inserting: "browser_style": true in the extension manifest. Styles like panel-section-footer-button become available. My question: How can you know how to use the default styles, there doesn't seem to be an official source or description of them? Related: The css in built-in resource chrome://browser/content/extension.css . This popup example on Mozilla site, which uses some default styles.. Using "browser_style": true

How to change firefox preferences (about:config) using the new WebExtensions api?

二次信任 提交于 2019-12-01 03:56:51
问题 To change the settings (about:config) with the old API you would simply do: require('sdk/preferences/service').set('media.webrtc.debug.multi_log', true); I can't find anything on the subject for the new WebExtensions add-ons of Firefox. Is it not available yet? 回答1: This is not possible, and likely, never will be. Source: official WebExtensions FAQ https://wiki.mozilla.org/WebExtensions/FAQ#Will_I_have_access_to_about:config_or_the_preferences.3F Also, you might be interested in this

Error: Content Security Policy: The page’s settings blocked the loading of a resource

二次信任 提交于 2019-12-01 00:50:11
I've been trying to move a simple program I made in jQuery/HTML to a Firefox WebExtension for easy deployment. The error I am getting is: Content Security Policy: The page’s settings blocked the loading of a resource at https://code.jquery.com/jquery-1.12.4.js (“script-src moz-extension://ef8f1295-1912-4912-ab2e-121053b6781a”). I'm sure I'm just not doing the manifest.json file right, but for the life of me I don't know where: { "description": "Makes tasks from different underwriters uniform", "manifest_version": 2, "name": "Task Creator", "version": ".5", "permissions": [ "http://*/*", "tabs"

Need workaround for calling alert() from background script

允我心安 提交于 2019-11-30 19:31:48
问题 Calling alert() from the background script is allowed in Google's Chrome, but not in Firefox (WebExtensions) which I am porting my Chrome extension to. So, I need a workaround to get an alert dialog up. I'm not asking for anything else other than THE alert dialog. Sending a message to a content script to call alert() will not suffice since no content scripts may be loaded at the time the alert call is needed. 回答1: My workaround is to save the alert code in a string like: var alertWindow =

Error: Content Security Policy: The page’s settings blocked the loading of a resource

依然范特西╮ 提交于 2019-11-30 18:12:51
问题 I've been trying to move a simple program I made in jQuery/HTML to a Firefox WebExtension for easy deployment. The error I am getting is: Content Security Policy: The page’s settings blocked the loading of a resource at https://code.jquery.com/jquery-1.12.4.js (“script-src moz-extension://ef8f1295-1912-4912-ab2e-121053b6781a”). I'm sure I'm just not doing the manifest.json file right, but for the life of me I don't know where: { "description": "Makes tasks from different underwriters uniform"

Promise support for Chrome Extensions API?

笑着哭i 提交于 2019-11-30 17:57:28
I've been writing some browser extensions in the last few weeks and until today I thought that a WebExtension for Firefox should work pretty much automatically in Chrome. So I tried to write my code according to Mozilla's examples. But today I realized that there is no mention of Promises in the API documentation for Chrome Extensions. I have strictly used Promises throughout the code for all my Extensions. So now my question is, will my code work in Chrome? Or would it work if I add a var browser = chrome declaration at the very top? Or does Chrome not support Promises on the API at all? If

tabs.getCurrent() result is undefined?

邮差的信 提交于 2019-11-30 14:40:09
Not sure why I cannot retrieve info about current tab using getCurrent() when I navigate to, say, amazon.com or google.com and hit the browser icon for a browser action. Any hints on what I am missing? MANIFEST: { "name": "testGetCurrentTab", "version": "1.0", "description": "", "manifest_version": 2, "icons": { "48": "icons/icon-48.png" }, "permissions": [ "tabs", "<all_urls>" ], "browser_action": { "default_icon": "icon/icon-32.png" }, "background": { "scripts": ["background.js"] } } BACKGROUND: function displayInfo() { function onGot(tabInfo) { console.log('Inside onGot() ...'); console.log