Giter Site home page Giter Site logo

Comments (7)

SanderRonde avatar SanderRonde commented on May 28, 2024

There indeed is not a tutorial for this extension. It's not that big of an extension and a tutorial would have to be very comprehensive

When it comes to storing data you will probably want to look at the crmAPI.storage API. With it you can permanently store data for a specific script. If you want to store it for just that website, you can use the localStorage API as well.

from customrightclickmenu.

erikdemarco avatar erikdemarco commented on May 28, 2024

I try to use basic script like this:

var value = "test";
        chrome.storage.local.set({key: value}, function() {
          console.log('Value is set to ' + value);
        });
      
        chrome.storage.local.get(['key'], function(result) {
          console.log('Value currently is ' + result.key);
        });

the console shows:
Value is set to test
Value currently is [object] (empty data)

why "chrome.storage.local.get" doesnt work?
I tick all the permission in "edit script", it got untick itself all the time.

from customrightclickmenu.

SanderRonde avatar SanderRonde commented on May 28, 2024

That's right, you can't use the chrome.storage APIs or any other chrome APIs. That is a security measure to prevent scripts from breaking/changing extension data (you would be writing your data to the same place the extension stores its data). That's why you should use the crmAPI.storage API instead. You can also use the crmAPI.browser API which is supposed to mimic the call signature of those chrome functions.

from customrightclickmenu.

erikdemarco avatar erikdemarco commented on May 28, 2024

when i'm doing this:

        crmAPI.browser.storage.local.set({key: value}, function() {
          console.log('Value is set to ' + value);
        });
      
        crmAPI.browser.storage.local.get(['key'], function(result) {
          console.log('Value currently is ' + result.key);
        });

it shows "crmapi.js:5 Looks like you didn't send your chrome function, set crmAPI.warnOnChromeFunctionNotSent to false to disable this message"

do i miss something?

from customrightclickmenu.

SanderRonde avatar SanderRonde commented on May 28, 2024

You have to call .send() at the end. So instead of

crmAPI.browser.storage.local.set({key: value}, function() {
    console.log('Value is set to ' + value);
});

do

crmAPI.browser.storage.local.set({key: value}, function() {
    console.log('Value is set to ' + value);
}).send();

There are some examples in the documentation i sent although the formatting has gone a bit bad.

Also you might want to call .get() in the callback of .set(), because otherwise the setting operations hasn't completed by the time you're calling .get()

from customrightclickmenu.

erikdemarco avatar erikdemarco commented on May 28, 2024

it shows "Error: Permission storage is not allowed for scripts, please use a CRM API"

I end up using CRM API storage. It works. I think this extension is really really powerful.

Maybe you should add more advanced example code in the tutorial. Currently your tutorial only show very basic code which is too bad because it can do many powerful things.

Btw thank you so much for making this extension. I will continue to learn by mistake. :)

from customrightclickmenu.

SanderRonde avatar SanderRonde commented on May 28, 2024

Good to hear that you got it working, I didn't know that the browser API didn't work.

I probably should add some more example code but I'm currently a bit busy. I'll try to get to it some time soon.

from customrightclickmenu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.