lulumi-browser icon indicating copy to clipboard operation
lulumi-browser copied to clipboard

Add WebExtensions APIs to support extensions from chrome and FF.

Open qazbnm456 opened this issue 8 years ago • 25 comments
trafficstars

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

qazbnm456 avatar May 19 '17 14:05 qazbnm456

Currently Implemented APIs

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

qazbnm456 avatar May 19 '17 14:05 qazbnm456

APIs needed for uBlock

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

qazbnm456 avatar Jun 09 '17 14:06 qazbnm456

APIs needed for thegreatsuspender

  • [x] contextMenus.remove(integer or string menuItemId, function callback)
  • [x] 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: https://github.com/brave/muon/issues/165 https://github.com/brave/browser-laptop/issues/253

qazbnm456 avatar Jun 21 '17 12:06 qazbnm456

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.

qazbnm456 avatar Aug 04 '17 03:08 qazbnm456

APIs needed for Virtual Keyboard

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

jeromevalentin avatar Dec 13 '17 09:12 jeromevalentin

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

82318179 avatar Jan 17 '18 05:01 82318179

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

qazbnm456 avatar Jan 17 '18 05:01 qazbnm456

APIs needed for Steward

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

qazbnm456 avatar Mar 21 '18 05:03 qazbnm456

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.

samuelmaddock avatar Apr 02 '18 02:04 samuelmaddock

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.

qazbnm456 avatar Apr 02 '18 06:04 qazbnm456

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

sentialx avatar Jul 30 '18 19:07 sentialx

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.

qazbnm456 avatar Jul 31 '18 01:07 qazbnm456

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

sentialx avatar Jul 31 '18 08:07 sentialx

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

qazbnm456 avatar Aug 01 '18 09:08 qazbnm456

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 avatar Aug 10 '18 12:08 qazbnm456

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

samuelmaddock avatar Aug 10 '18 14:08 samuelmaddock

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

sentialx avatar Aug 28 '18 16:08 sentialx

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

stewartlord avatar Jan 09 '19 00:01 stewartlord

@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.

qazbnm456 avatar Jan 13 '19 09:01 qazbnm456

thanks

wangfei1988 avatar Feb 15 '19 07:02 wangfei1988

可以支持安卓 和ios吗

wangfei1988 avatar Feb 15 '19 07:02 wangfei1988

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

qazbnm456 avatar Feb 17 '19 09:02 qazbnm456

@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. 🙂

samuelmaddock avatar Mar 09 '19 07:03 samuelmaddock

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

qazbnm456 avatar Mar 22 '19 11:03 qazbnm456

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

minpoo avatar Jun 14 '19 08:06 minpoo