MozillaZine

Accessing WebExtensions world from chrome

Talk about add-ons and extension development.
pintassilgo
 
Posts: 166
Joined: August 30th, 2013, 3:50 pm

Post Posted January 15th, 2020, 8:16 pm

For instance, how to run
Code: Select all
browser.runtime.sendMessage()

and
Code: Select all
browser.tabs.create(

from Browser Console?

The thing is: how to access browser object?

morat
 
Posts: 3638
Joined: February 3rd, 2009, 6:29 pm

Post Posted January 16th, 2020, 12:12 pm

A few years ago, I tried to create the browser object in the browser console. I couldn't figure out how to run code like "class extends ExtensionAPI" in the browser console.

browser.runtime
http://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/runtime
http://searchfox.org/mozilla-release/source/toolkit/components/extensions/parent/ext-runtime.js
http://searchfox.org/mozilla-release/source/toolkit/components/extensions/child/ext-runtime.js

browser.tabs
http://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/tabs
http://searchfox.org/mozilla-release/source/browser/components/extensions/parent/ext-tabs.js
http://searchfox.org/mozilla-release/source/browser/components/extensions/child/ext-tabs.js

Try using the console in the about:debugging page.

* open about:debugging
* left click This Firefox on the left side
* left click inspect button next to an extension
* copy and paste code into the console
* press enter to run

Code: Select all
(function () {
  browser.tabs.create({
    "url": "http://www.example.com/",
  });
})();

Debugging
http://developer.mozilla.org/Add-ons/WebExtensions/Debugging

Return to Extension Development


Who is online

Users browsing this forum: No registered users and 1 guest