firefox-webextensions

How to use chrome.storage and runtime.connect in a Firefox WebExtensions add-on

血红的双手。 提交于 2019-12-11 05:53:17
问题 I'm trying to create a Firefox add-on that does the following: sends a message to a background script when the page body is clicked the sent message is stored by the background script the stored message is retrieved by the background script when the add-in browser button is clicked that stored message is sent from the background script to the content script the content script displays the received message I'm using Firefox version 48 for windows and I can't get it to work. Can someone point

How to test firefox plugin locally

旧巷老猫 提交于 2019-12-11 05:18:47
问题 I have a basic Google Chrome extension which needs to be ported to Firefox. I uploaded the .crx file to the Firefox marketplace and it got accepted but is under review rightnow. I downloaded the the generated xpi file and tried to install it locally but without any success. It tell that the plugin is invalid or corrupted. Another method that I tried is I ported the extension using chrome-tailor and generated the xpi. I am able to install the extension in this but the content scripts are not

Firefox Web Extension “selectionchange”

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 05:18:38
问题 I'm trying to write cross browser Web Extension. Based on selected value on web page I want to create appropriate entry in context menu. I created a sample code to check if browser is entering to Event Listener. In Chrome it's all working fine, but in firefox following code is not being executed. console.log("Content script entry"); document.addEventListener('selectionchange', function() { debugger; console.log("CS Add Event"); }); Could you please help? Best regards Frank 回答1: I believe

Firefox native messaging through webextension

孤人 提交于 2019-12-11 04:14:28
问题 Created a webextension for firefox (currently using Nightly 52), that uses native messaging to launch a java program on Linux (Ubuntu 14, 32x). The webextension loads, reads the .json file and reads the path which points to a script that starts the java program. The JSON and the path are correct as when I use: var native = browser.runtime.connectNative("passwordmanager"); console.log("native.name" + native.name); //outputs passwordmanager. native.onDisconnect.addListener(function(m) { console

Updating self-hosted extensions through HTTP

巧了我就是萌 提交于 2019-12-11 01:48:19
问题 I'm transforming my SDK-based Firefox extension to WebExtensions and I've come to the issue of updating the extension. The current extension is hosted on my own domain (which is an HTTP domain), along with the update.rdf file. Now, for SDK-based add-ons, updates were possible via HTTP as long as the update manifest was signed using the McCoy tool and the valid hash of the update file was provided in the manifest. In addition to that, install.rdf would hold the public key portion of the key

Firefox extension content script does not load and append HTML

一曲冷凌霜 提交于 2019-12-10 22:09:18
问题 Everything below works in a Chrome extension but silently fails when ported to Firefox on: loading the test.html unless I remove <style></style> from it appending the #test_element to the body Do styles have to go into a separate file for Firefox extension? Why does append() fail? test.js $(document).ready(function() { $.get(chrome.extension.getURL('/html/test.html'), function(data) { // not called unless style element is removed from HTML // and never actually appended if it is removed $

WebExtension: React when a a tab is reloaded

元气小坏坏 提交于 2019-12-10 18:48:52
问题 I am working on a Firefox WebExtension which has a popup and uses chrome.storage.local to store state. So far, I have got it to store data for specific tabs using the tab id. I would like to reinitialize the local storage if the current tab is reloaded. This is because the extension may have made some changes to the DOM which will be lost if the tab is reloaded; what state it has stored is therefore incorrect. The initial JavaScript code is called from the popup. How can I run some code when

Firefox WebExtensions and Cross-domain privileges

你说的曾经没有我的故事 提交于 2019-12-09 10:57:45
问题 I am trying to port a chrome extension to firefox using the relatively new WebExtensions from Firefox. I always getting the following error Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at .... (Reason: CORS header 'Access-Control-Allow-Origin' missing) I added the website i would like to access to the permissions section inside the manifest.json like explained on the website, and also on Google Chrome its working. Normally it should work that way,

WebExtensions: How to send a message to content script? (Android)

假如想象 提交于 2019-12-08 22:34:03
问题 I just noticed that the tabs API is only available for the desktop not for Android. In the past I have used this code to send messages to my content scripts: sendMsgToTabs(msg) { return browser.tabs.query({}).then(tabs => { let msgPromises = [] for (let tab of tabs) { let msgPromise = browser.tabs.sendMessage(tab.id, msg) msgPromises.push(msgPromise) } return Promise.all(msgPromises) }) } But how am I supposed to do that when the tabs API is not available? I mean the only thing I can think of

Use database in the Firefox web extension

微笑、不失礼 提交于 2019-12-08 12:56:17
问题 I want to use some database in my Firefox web extension, I already found this, but it's just a storage for key-value pairs. So how can I use database in the Firefox web extension? 回答1: You can use the IndexedDB Web API: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API There's a sample extension that uses it, though it's using a library. It might be better to look at general Using IndexedDB examples. You probably want to declare "unlimitedStorage" permission; in Chrome, it lifts