firefox-webextensions

Access old-style Firefox extension's preferences when porting to WebExtensions

烈酒焚心 提交于 2020-01-06 05:39:12
问题 My XUL-based Firefox extension stores data in preferences. Is there a way to access this data once when migrating to a WebExtension version? I am aware of https://wiki.mozilla.org/WebExtensions/FAQ#Does_the_WebExtensions_API_provide_access_to_preferences.3F but hope there is a solution for this specific use-case. 回答1: Depending on the number of preferences, there are a few options: discard them and let your users set them again after upgrading read them using an external program which

webRequest API: How to get the requestId of a new request?

狂风中的少年 提交于 2020-01-05 08:48:51
问题 The chrome.webRequest API has the concept of a request ID (source: Chrome webRequest documention): Request IDs Each request is identified by a request ID. This ID is unique within a browser session and the context of an extension. It remains constant during the the life cycle of a request and can be used to match events for the same request. Note that several HTTP requests are mapped to one web request in case of HTTP redirection or HTTP authentication. You can use it to correlate the

tabs.onUpdated.addListener's changeInfo.status goes from undefined to Complete without ever going to loading

我是研究僧i 提交于 2020-01-05 04:23:22
问题 I see this behavior only when google SERP page is loading (when searched from the search box on google.com/ or box on SERP page it self). I was seeing expected behavior for other pages i.e., I see undifined, loading and finally a complete. chrome.tabs.onUpdated.addListener( function(tabId, changeInfo, tab){ console.log(changeInfo.status); // prints undefined couple of times and then completed (no sign of loading). } I'm working on extension that behaves differently depending on tabs status.

Connect C++ native app to Firefox WebExtensions add-on with native messaging

吃可爱长大的小学妹 提交于 2020-01-05 02:36:28
问题 I want to make a easy example Firefox add-on using Native messaging. Here is my code: Native App: void SendDataToExtension(string message) { _setmode(_fileno(stdout), O_BINARY); try { unsigned int len = message.length(); std::string message = "{\"text\": \"This is a response message\"}"; unsigned int lenStr = str.length(); std::cout << char(((lenStr >> 0) & 0xFF)) << char(((lenStr >> 8) & 0xFF)) << char(((lenStr >> 16) & 0xFF)) << char(((lenStr >> 24) & 0xFF)); std::cout << str.c_str(); std:

Install a personal firefox web extension permanently

允我心安 提交于 2020-01-01 09:07:07
问题 Previously, I could write an addon for personal usage packed as something.xpi and I clicked on it to install it. After a while, mozilla introduced xpinstall.signatures.required which you could still get around it. However, it did not stop stabbing developers who are interested to have a personal addon isolated from the world. Today, only web extensions are working and my XUL based addon is thrown away. The tutorials only talk about temporary installation of a web extension while I want my one

Copy text to clipboard from background script in a Firefox WebExtension

人走茶凉 提交于 2019-12-31 04:00:05
问题 I am porting my Chrome extension over to Firefox. It has a paste to clipboard function. But, I have not yet had any luck with doing that in Firefox. Here is what I am trying to do in my background script: const input = document.createElement('textarea'); input.style.position = 'fixed'; input.style.opacity = 0; input.value = text; document.body.appendChild(input); input.select(); document.execCommand('copy'); logger(text); document.body.removeChild(input); This works fine in Chrome. I have the

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

流过昼夜 提交于 2019-12-30 09:38:35
问题 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 .

Chrome extension detect Google search refresh

心已入冬 提交于 2019-12-29 09:32:09
问题 How can my content script detect a refresh of Google's search? I believe it is an AJAX reload of the page and not a "real" refresh, so my events won't detect the refresh. Is it possible to detect it somehow in both a Google Chrome extension and a Firefox WebExtensions add-on? 回答1: Google search is a dynamically updated page. Several well-known methods exist to detect an update: MutationObserver, timer-based approach (see waitForKeyElements wrapper), and an event used by the site like pjax:end

Firefox WebExtensions, get local files content by path

霸气de小男生 提交于 2019-12-29 06:00:34
问题 I'm trying to write a small add-on for firefox using the WebExtensions structure. This add-on should read a local file content by it's absolute path: "/home/saba/desktop/test.txt" manifest.json { "manifest_version": 2, "name": "Test - load files", "version": "0.0.1", "description": "Test - load files", "permissions": [ "<all_urls>" ], "background": { "scripts": [ "main.js" ] } } Here what I tried so far (inside the main.js): Using XMLHttpRequest function readFileAjax(_path){ var xhr = new

Firefox WebExtensions, get local files content by path

廉价感情. 提交于 2019-12-29 06:00:32
问题 I'm trying to write a small add-on for firefox using the WebExtensions structure. This add-on should read a local file content by it's absolute path: "/home/saba/desktop/test.txt" manifest.json { "manifest_version": 2, "name": "Test - load files", "version": "0.0.1", "description": "Test - load files", "permissions": [ "<all_urls>" ], "background": { "scripts": [ "main.js" ] } } Here what I tried so far (inside the main.js): Using XMLHttpRequest function readFileAjax(_path){ var xhr = new