LulumiProject/lulumi-browser

Add WebExtensions APIs to support extensions from chrome and FF.

qazbnm456 opened this issue · 25 comments

We now have electron/electron#5842 for Accessibility DevTools extension.
How about implementing more WebExtensions APIs to support more extensions that are on chrome and FF.

Currently Implemented APIs

  • browserAction.onClicked
  • pageAction.setIcon(object details, function callback)
  • pageAction.pageAction.show(integer tabId)
  • pageAction.hide(integer tabId)
  • pageAction.onClicked
  • alarms.get(string name, function callback)
  • alarms.getAll(function callback)
  • alarms.clear(string name, function callback)
  • alarms.clearAll(function callback)
  • alarms.create(string name, object alarmInfo)
  • alarms.onAlarm
  • commands.onCommand
  • runtime.id
  • runtime.getURL(string path)
  • runtime.sendMessage(string extensionId, any message, object options, function responseCallback)
  • runtime.onMessage
  • extension.getURL(string path)
  • extension.getBackgroundPage()
  • tabs.get(integer tabId, function callback)
  • tabs.getCurrent(function callback)
  • tabs.duplicate(integer tabId, function callback)
  • tabs.query(object queryInfo, function callback)
  • tabs.update(integer tabId, object updateProperties, function callback)
  • tabs.reload(integer tabId, object reloadProperties, function callback)
  • tabs.remove(integer or array of integer tabIds, function callback)
  • tabs.detectLanguage(integer tabId, function callback)
  • tabs.executeScript(integer tabId, object details, function callback)
  • tabs.insertCSS(integer tabId, object details, function callback)
  • tabs.sendMessage(integer tabId, any message, object options, function responseCallback)
  • tabs.onUpdated
  • tabs.onCreated
  • tabs.onRemoved
  • windows.get(integer windowId, object getInfo, function callback)
  • windows.getCurrent(object getInfo, function callback)
  • windows.getAll(object getInfo, function callback)
  • storage.local
  • storage.sync
  • storage.set(object items, function callback)
  • storage.get(string or array of string or object keys, function callback)
  • storage.onChanged
  • contextMenus.create(object createProperties, function callback)
  • webRequest.onBeforeRequest(function callback)
  • webRequest.onBeforeSendHeaders(function callback)
  • webRequest.onSendHeaders(function callback)
  • webRequest.onHeadersReceived(function callback)
  • webRequest.onResponseStarted(function callback)
  • webRequest.onBeforeRedirect(function callback)
  • webRequest.onCompleted(function callback)
  • webRequest.onErrorOccurred(function callback)
  • webNavigation.getFrame(details, function callback)
  • webNavigation.getAllFrames(details, function callback)
  • webNavigation.onBeforeNavigate(function callback)
  • webNavigation.onCommitted(function callback)
  • webNavigation.onDOMContentLoaded(function callback)
  • webNavigation.onCompleted(function callback)
  • webNavigation.onCreatedNavigationTarget(function callback)

APIs needed for uBlock

  • tabs.onActivated
  • storage.remove(string or array of string keys, function callback)
  • i18n.getAcceptLanguages(function callback)
  • i18n.getMessage(string messageName, any substitutions)
  • i18n.getUILanguage()
  • i18n.detectLanguage(string text, function callback)
  • runtime.getManifest()
  • runtime.onConnect
  • browserAction.setIcon(object details, function callback)
  • browserAction.setBadgeText(object details)
  • contextMenus.onClicked
  • browserAction.setBadgeBackgroundColor(object details) only support "string: color" now
  • windows.update(integer windowId, object updateInfo, function callback)

APIs needed for thegreatsuspender

  • contextMenus.remove(integer or string menuItemId, function callback)
  • contextMenus.removeAll(function callback)
  • extension.getBackgroundPage()
  • extension.getViews()

Some extension APIs need to be implemented by writing some C++ code in the lower layer, such as extension.getBackgroundPage and extension.getViews.

Will consider writing on my own or use Muon instead, though lots of code will have to be rewritten because Muon has removed the support for running Node.js in renderer processes.
Ref: brave/muon#165 brave/browser-laptop#253

APIs needed for Grammarly for Chrome

  • windows.onFocusChanged
  • cookies.onChanged
  • extension.isAllowedIncognitoAccess(function callback)

We can extract the source code from .crx file through http://crxextractor.com/ or via https://github.com/6IX7ine/cromos.

APIs needed for Virtual Keyboard

  • extension.onRequest
  • extension.sendRequest(string extensionId, any request, function responseCallback)
  • extension.getURL(string path)

这个浏览器现在支持windows吗?

@82318179 支持,但還有很多功能未完善。

APIs needed for Steward

  • extension.onRequest
  • extension.getURL(string path)
  • extension.sendRequest(string extensionId, any request, function responseCallback)
  • i18n.getMessage(string messageName, any substitutions)
  • runtime.sendMessage(string extensionId, any message, object options, function responseCallback)
  • runtime.getManifest()
  • storage.onChanged
  • management.getAll(function callback)
  • tabs.create(object createProperties, function callback)
  • i18n.getUILanguage()

Hey @qazbnm456, I just discovered your project and was wondering if you had any plans to contribute these API additions back into the main electron repo.

Hi @samuelmaddock, there's no such a plan to contribute these API additions back to electron currently since several dirty hacks have been done in this repo. But I'm thinking about making these API as a package to provide a way injecting them to existing electron apps like https://github.com/koush/electron-chrome.

Maybe after finishing the package mentioned above, I'll try to clean up the implementations and pick some back to upstream.

Thanks for your question.

Hi @qazbnm456. Have you managed how to impement extension.getBackgroundPage() in C++?

Hi @Sential, I was busy before, so I didn't have the spare time figuring out how to implement it. I'll tackle this problem in the near future by mimicking the implementation of chrome.

Have you got Discord? Mine is Sential#9122. I want to talk about extensions API with you.

@Sential I don't have one. I'll add and chat with you on weekend, perhaps, if I have time. Thank you!

Been spending several days looking into extension system of chromium and found out that some extension APIs need lots of effort to be implemented, e.g. extension.getBackgroundPage() and extension.getViews().

Would revisit them again after electron migrates to OOPIF architecture.

@qazbnm456 Checkout Muon if you need a reference. They have a good amount of the extensions API implemented. https://github.com/brave/muon

@qazbnm456 Have you managed to get uBlock Origin's cosmetic filtering to work?

@qazbnm456 Any further progress implementing extension.getBackgroundPage()?

@stewartlord No, still have some problems making it work. It's more complicated than I expected and I'll look into it again when I'm available sometime.

thanks

可以支持安卓 和ios吗

@wangfei1988 很抱歉,沒有喔!Lulumi 底層是 Electron,而 Electron 沒有支援 Android 和 IOS。

@qazbnm456 i wanted to point out that i've been contributing to electron to add better support for chrome extensions https://github.com/electron/electron/pulls/samuelmaddock

soon i'll be looking into supporting additional chrome.* APIs. send me an email, listed on my profile, if you'd be interested in helping out. 🙂

Hi @samuelmaddock, it's great to have you in Electron team so as to push the implementation of chrome.* APIs better.

点击关闭浏览器后,进程没有被杀死,在window上,第二次打开导致失败,怎么解决