Filter-Bubble / Web-Extension-Shim

This repository contains a JavaScript shim (polyfill) for some Chrome Extension API calls.
Apache License 2.0
19 stars 4 forks source link

Would you consider adding more shims? #1

Open abalter opened 2 years ago

abalter commented 2 years ago

This is sort of a feature request, but moreso, a shameless request for help with MY project.

I'm trying to port a chrome app to be a web app. I found this shim and it's doing a lot of the work. There are still some chrome API methods that need to be covered. I'm not a javascript or web programmer, but I'm kind of trying to build a proof-of-concept thing.

In particular, this is the list of chrome methods used in my app vs. ones already in the shim.

Chrome Methods Needed for My App

Right now (in this branch) the error I get is

jQuery.Deferred exception: chrome.storage.sync is undefined IdeSettingsHandler/this.init@http://localhost/codepad-chrome-app/src/js/handlers/ide.settings.js:70:9

https://github.com/abalter/codepad-webapp/blob/chrome-storage-sync-problem/src/js/handlers/ide.settings.js#L70

coder0107git commented 1 year ago

@abalter The chrome.storage.sync is undefined error can be solved by adding

sync: {
    set: function(...params) { 
        browser.storage.local.set(...params);
    },
    get: function(...params) {
        return browser.storage.local.get(...params); 
    },
},

after Line 87 in your WebExtensionShim.js file. Note: The code only works on these browsers without transpilation. If you need more browsers to be supported use a transpiler like Babel.js. I made an example JSFiddle here.