firefox-webextensions

How can I use navigator.clipboard.readText() in a Chrome extension?

☆樱花仙子☆ 提交于 2020-07-03 07:59:02
问题 I wrote a Firefox extension that reads the clipboard and if it has some PEM certificate, it will print it's details in a new tab. I'm trying to port to Chrome. It does not work. What am I doing wrong? I asked for the clipboardRead in manifest.json and I run this in background script and it works fine in Firefox. navigator.clipboard.readText().then(function (textFromClipboard) { //do stuff with textFromClipboard }); This fails in Chrome with "Failed to execute 'readText' on 'Clipboard':

How can I use navigator.clipboard.readText() in a Chrome extension?

荒凉一梦 提交于 2020-07-03 07:57:49
问题 I wrote a Firefox extension that reads the clipboard and if it has some PEM certificate, it will print it's details in a new tab. I'm trying to port to Chrome. It does not work. What am I doing wrong? I asked for the clipboardRead in manifest.json and I run this in background script and it works fine in Firefox. navigator.clipboard.readText().then(function (textFromClipboard) { //do stuff with textFromClipboard }); This fails in Chrome with "Failed to execute 'readText' on 'Clipboard':

How to know if a new tab is opened by user click on new tab button?

倾然丶 夕夏残阳落幕 提交于 2020-05-15 19:39:12
问题 In Firefox WebExtensions, how to know in which way is the new tab opened? By user click on the new tab button (+)? By User click on a link such as <a href="http://www.google.com/"> ? Note: I don't care if a new tab is opened by window.open() I found that, in callback of chrome.tabs.Tab.onCreated , there is a parameter passed in, assume it is named as firefoxTab : For tabs opened by click on +, its URL is about:newtab For tabs opened by click on <a href="" target="_blank"> , its URL is about

Different development and build configuration with web-ext

我是研究僧i 提交于 2020-05-15 08:46:25
问题 I am working with a browser extension project and want to have a different URL used in background.js during development time and build time. I want to do this without having to remember to change the code between development and build. With a server project I'd simply use dotenv/environment variables but that's not available to extensions which effectively run client side. In background.js I have a fetch using this api_base_url (we develop the API too); ... const api_base_url = 'http://127.0

How do I get the fully qualified URL for a file inside my extension?

蓝咒 提交于 2020-01-30 08:33:07
问题 I am making my first Firefox extension using the WebExtension API and cannot find a way to redirect a website to an HTML file that is in the extension's directory. I have already managed to redirect the website but only to other websites or other pages on the website. manifest.json: { "manifest_version": 2, "name": "Focus", "version": "1.0", "permissions": [ "activeTab" ], "browser_action": { "default_title": "Focus", "default_popup": "interface/main.html" }, "content_scripts": [ { "matches":

How to use cloneInto in a Firefox web extension?

穿精又带淫゛_ 提交于 2020-01-25 09:16:06
问题 I am trying to write a web extension where I need to pass an object from the content script to the page script. I have looked at, among others, https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_scripts#Sharing_content_script_objects_with_page_scripts and https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.utils.cloneInto I want to use the cloneInto function described there. There is a code example that looks like this: // this happens in

Add a firefox webextension when installing the native host application

别等时光非礼了梦想. 提交于 2020-01-24 19:35:07
问题 I have created a firefox webextension that communicates with a native host application. I also have created an installer for the native host application. Is there a way to enable the extension on the firefox when installing the native host application, via windows registry maybe. Thanks in advance. 回答1: You can install using the registry, as documented at: https://developer.mozilla.org/en-US/Add-ons/Adding_extensions_using_the_Windows_registry For general instructions that include platforms