peraperakun / chinese-chrome

7 stars 13 forks source link

Port to WebExtensions (Firefox)? #4

Open yoasif opened 6 years ago

yoasif commented 6 years ago

It should be (hopefully) fairly easy to port - https://developer.mozilla.org/en-US/Add-ons/WebExtensions

You know you have users that want this, they'll be pleased for a port!

andreicristianpetcu commented 6 years ago

I tried a port.... but it uses a deprecated Chrome API and Firefox does not implement deprecated chrome APIs. It uses this https://developer.mozilla.org/ro/Add-ons/WebExtensions/API/extension/sendRequest instead of this https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/sendMessage

This is just the first issue I bumped into. I don't know this extension, I am not a user.... I just help out people who want to switch from Chrome to Firefox.

https://twitter.com/metonymyqt/status/947185482835906565

andreicristianpetcu commented 6 years ago

I basically did this https://vimeo.com/241435808 this is the list of APIs Firefox supports https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs

I also changed the manifest.json to this:

{
   "background": {
      "scripts": [ "data.js", "cperapera.js", "background.js" ]
   },
   "browser_action": {
      "default_icon": "images/toolbar-disabled.png",
      "default_title": "Perapera Chinese Popup Dictionary"
   },
   "content_scripts": [ {
      "all_frames": true,
      "js": [ "cperacontent.js" ],
      "matches": [ "\u003Call_urls>" ]
   } ],
   "description": "Put your mouse over any Chinese words on a webpage and it gives you the pronunciation and definition. Simple as that!",
   "icons": {
      "128": "images/icon128.png",
      "16": "images/icon16.png",
      "48": "images/icon48.png"
   },
   "manifest_version": 2,
   "name": "Perapera Chinese Popup Dictionary",
   "options_ui": {
    "page": "options.html"
   },
   "permissions": [ "tabs", "http://*/*" ],
   "version": "1.1.0",
   "web_accessible_resources": [ "css/*", "cperacontent.js", "images/*" ]
}