Chrome Extension -- Pass an array from popup.js into injected javascript file -


So close, so far ...


I'm writing a Chrome extension In which a user adds / deletes an item to a list. This ; then and

  • gt; Elements are stripped, and they are included in a local storage item as a linked list. This list is processed in an function and an array is created.

    Send me popup.js into the content script & lt; Script & gt; is running, inject.js , which is injected into a page. On one hand, I have made all the necessary manifest entries. I have read the chrome extension documentation, and many stack-overflow answers, yet I have not yet understood a clear idea of ​​what to do to wrap the argument passing through the array in a function which only provides the array Inject.js for

    We say that the array is created like this in popup.js:

      // popup.js var list inside; Function getlist () {listings ["list"] = local storage ["myAwesomeList"] the division ("**% **"); Return list; } Function sendListToInjectJs () {list = getList (); // Some amazing codes that make me available to my script inject.js}  

    As shown above, I need a function called, created array Injects .js where it is placed in a variable for processing:

    prefix // in inject.js var list = listPassedFromPopupJs; // sweet list processing here

    I really think that I have found it as easy as it should be. It seems that I should be able to say inject.js , "Hey, here's an updated version of that array, do something with it."

    Thank you for completing any insight into how to accomplish this !!! After the adoption of this bridge, my expansion will be completed.

  • you can use

    your popup To send an ARM to .js :

      chrome.tabs.sendMessage (tab [0] .id, [1,2,3] + ""); To get an array in  

    inject.js :

      chrome.runtime.onMessage.addListener (function (message) {Console.log (message.split (","))}};  

    Comments

    Popular posts from this blog

    ios - How do I use CFArrayRef in Swift? -

    eclipse plugin - Run java code error: Workspace is closed -

    c - Error on building source code in VC 6 -