firefox-webextensions

Firefox WebExtention API: TypeError: browser.browserAction is undefined [duplicate]

匆匆过客 提交于 2019-11-27 07:10:46
问题 This question already has an answer here: TypeError: [API] is undefined in content script or Why can't I do this in a content script? 2 answers While migrating my old Firefox add-on to WebExtension API, failed to understand while I am getting this error: TypeError: browser.browserAction is undefined Here is the manifest.json: { "manifest_version": 2, "name": "My Login", "version": "3.0", "description": "Login to my page", "homepage_url": "https://localhost", "icons": { "48": "icons/button-1

How to create a global hotkey for opening the “browserAction” popup in Firefox (WebExtensions)?

主宰稳场 提交于 2019-11-27 02:02:19
It seems Chrome doesn't have an API to open the popup, but has a dedicated system for doing it with a hotkey: _execute_browser_action key in commands . The special functionality of _execute_browser_action in commands is not supported( 1 ) by Firefox. The type of popup I care about is browserAction , not pageAction . How can I have the browserAction popup open when a keyboard shortcut/hotkey combination is pressed? Available natively in Firefox versions >= 52 This functionality will be natively available in Firefox 52, which is currently Firefox Developer Edition (i.e. Firefox 52.0a2). As you

Show HTML file contained within the extension

孤人 提交于 2019-11-26 23:43:18
问题 I'm creating a website blocker: after you visit a website you've blocked, the browser displays a new HTML page saying "website blocked". The new HTML page is saved in my Chrome extension as message.html . Is there any way to display message.html in the browser? If not, I'll just use a content script to inject some JavaScript. 回答1: Updating a tab to display message.html Assuming all of the following are true: You are doing this from a script running in the background context. You are wanting

TypeError: [API] is undefined in content script or Why can't I do this in a content script?

故事扮演 提交于 2019-11-26 23:04:55
I was trying to write a simple extension in Firefox wherein I modify the X-Frame-Allow header. I looked at the documentation briefly and I see that they support webRequest.onHeadersReceived.addListener() . However, I'm unable to get my code to run when the headers are received. manifest.json { "manifest_version": 2, "name": "xframeoptions", "version": "1.0", "description": "Set X-Frame-Options to ALLOW", "icons": { "48": "icons/icon.png" }, "permissions": [ "webRequest", "webRequestBlocking", "<all_urls>" ], "content_scripts": [ { "matches": ["<all_urls>"], "js": ["xframeoptions.js"] } ] }

Completely lost on how to save extension popup window content

谁说胖子不能爱 提交于 2019-11-26 23:04:27
I'm pretty much lost on how to make the added contents of my popup window not disappear every time I open a new link or click it "away". I've read about content script, background script and the like but I don't honestly know how to implement that into my own source code. Below is my popup.html , popup.js and my manifest.js file. { "manifest_version": 2, "name": "URL_save", "description": "This extension saves an URL and renames the title to the user's wishes and hyperlink the title.", "version": "0.1", "browser_action": { "default_icon": "/img/icon.png", "default_popup": "popup.html",

Firefox WebExtension settings page

守給你的承諾、 提交于 2019-11-26 21:40:09
问题 I have a settings page on my WebExtension, but I dont know how to acces the values of the settings with javascript. Current .xul-File: <?xml version="1.0"?> <!DOCTYPE mydialog SYSTEM "chrome://myaddon/locale/mydialog.dtd"> <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <setting type="string" pref="extensions.check.email" title="email" desc="please insert your email here" /> </vbox> How do I acces the "email" value? Can I just write something like "getPreferences(

Firefox WebExtension importing Services

穿精又带淫゛_ 提交于 2019-11-26 17:25:57
问题 I am feeling overwhelmed by so many different approaches, guides, and yet none I tried work for me. Please connect at least some of the dots for me... My objective is to find a window object in background script of Firefox WebExtension. Problem, I cannot import Services library to use it for finding a window object. Two methods I tried: Components.utils.import("resource://gre/modules/Services.jsm"); Gives a warning that Components is depricated, and an error: Components.utils is undefined.

Firefox extension .xpi file structure: description, contents, creation, and installation

ぃ、小莉子 提交于 2019-11-26 16:44:26
I put a lot of stuff in searching an easy way to develop a Firefox extension, but I am unable to create an extension. Kindly tell me the file structure of Firefox extensions and an easy way to install the extension. .xpi file format ( Extension Packaging ) The .xpi files that are used as containers for Mozilla (Firefox, Thunderbird, etc.) extensions are merely zip archives that have had the file extension changed to .xpi with the files added to the archive using either "deflate" compression, or uncompressed. If you use any other type of compression, other than "deflate", or "store"

How I can make a browser action button that looks and acts like a toggle

試著忘記壹切 提交于 2019-11-26 14:38:59
问题 The target is get a WebExtension for Firefox that can be activated/deactivated by a user in the toolbar, like an on/off switch. I'm using a background.js with this code: browser.browserAction.onClicked.addListener(function (tab) { switch (button) { case 'turn-on': enable(); break; case 'turn-off': disable(); break; } }); function enable() { browser.browserAction.setIcon({ path: '/ui/is-on.png', }); browser.browserAction.setPopup({ popup: '/ui/turn-off.js', }); browser.webNavigation

Communicate between scripts in the background context (background script, browser action, page action, options page, etc.)

ⅰ亾dé卋堺 提交于 2019-11-26 11:53:18
I am running into an issue sending data from my background script to the script for my pageAction . My content script adds an <iframe /> and the JavaScript in the <iframe /> is receiving the data from my background script, but it does not seem to be retrieved in my pageAction . In my background script I have something like: chrome.tabs.sendMessage(senderTab.tab.id, { foo:bar }); where senderTab.tab.id is the "sender" in onMessage Listener in my background script. In the JavaScript loaded by the <iframe /> injected by my content script I have something like: chrome.runtime.onMessage.addListener