firefox-webextensions

Modify the browser UI using extensions?

左心房为你撑大大i 提交于 2019-11-30 14:24:16
问题 Is there an API to modify the general browser UI in Chrome extensions or WebExtensions? For example I would like to modify the tab bar so that it can display multiple rows of tabs without creating a toolbar that sits below the address bar. Or simply add some styling to the navigation bar etc. I can't seem to find an API that would allow you to do anything like that. 回答1: No, there is nothing in either Chrome extensions or WebExtensions that allows you to modify the browser UI to the extent

tabs.getCurrent() result is undefined?

百般思念 提交于 2019-11-30 05:34:11
问题 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"] } }

Using chrome.tabs vs browser.tabs for browser compatibility

南笙酒味 提交于 2019-11-30 02:48:51
问题 I'm porting my Chrome extension to Firefox. According to MDN there is a browser.tabs API which should be supported by chrome. However browser is not an object in Chrome stable. At the same time chrome.tabs works just fine in Firefox. Is it safe to replace browser with chrome when reading the MDN docs? What is the reason for the docs to write browser ? Is there are planned change coming? 回答1: Note: In the last couple days, many of the MDN JavaScript API pages have been changed from using

Promise support for Chrome Extensions API?

荒凉一梦 提交于 2019-11-30 02:42:29
问题 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

What and where exactly are privileged code, chrome code, Gecko?

陌路散爱 提交于 2019-11-29 17:55:10
In reading about the File API and wanting to write data directly from an indexedDB database to the client disk instead of first building and holding a large blob in RAM to download to disk, there are a few basic items I'm not understanding. In the MDN documents these two statements are found: In Gecko, privileged code can create File objects representing any local file without user interaction. If you want to use the DOM File API in chrome code, you can do so without restriction. In fact, you get one bonus feature: you can create File objects specifying the path of the file on the user's

Chrome extension detect Google search refresh

天涯浪子 提交于 2019-11-29 16:55:16
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? 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 on GitHub. Luckily, Google Search in Chrome browser uses message event, so here's our content script:

Unable to use Components in WebExtensions: get “ReferenceError: Cu is not defined”

吃可爱长大的小学妹 提交于 2019-11-29 16:24:59
I have a simple extension where I use Cu.import to import a JavaScript code module . But, when I load the extension, I get this error: Cu is not defined The code I was trying to use was: Cu.import("resource://gre/modules/MatchPattern.jsm"); Cu.import("resource://gre/modules/BrowserUtils.jsm"); var regExArray = []; var myArray = ["facebook.com", "google.com"]; var myURL="http://www.google.co.uk/?gfe_rd"; for (var x=0; x<myArray.length; x++) { console.log("loop: "+x); var match = new MatchPattern(/(http:\/\/)(.*\.)*(myArray[x])(\/.*)*(\/)*/); log("match result is: "+match.matches(myURL)); }//end

Communicate data from popup to content script injected by popup with executeScript()

一曲冷凌霜 提交于 2019-11-29 09:35:36
问题 I have a text area and a button in my Chrome extension popup. I want users to input desired text in the text area. Then, once they click the button, it will inject a content script to change the text of the fields on the current page that have <textarea class="comments"> to the text that user entered in the <textarea> in the Chrome extension popup. My question is, how can I get the text from the <textarea> in my popup.html and pass it from the popup.js to the content script? This is what I

How to determine in which browser your extension background script is executing?

こ雲淡風輕ζ 提交于 2019-11-29 08:24:48
I'm talking about Chrome extensions, Firefox WebExtensions, Edge extensions... In a background script, not a content script, is there a clear way to know which browser I am using? I need to do different operations for different browsers. Yes, navigator.userAgent can be useful, but it's not very clear . Is there any extension API that can be used to do this? Something like, chrome.extension.browserType . (Of course, this one doesn't really exist..) Makyen There is no specific API to detect which browser is currently being used. One of the benefits of the major browsers moving to support a

Firefox WebExtensions, get local files content by path

ε祈祈猫儿з 提交于 2019-11-29 03:55:05
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 XMLHttpRequest(); xhr.onloadend = function(event) { console.log("onloadend", this); }; xhr