S
S
Sergey2017-12-05 13:17:02
JavaScript
Sergey, 2017-12-05 13:17:02

How to pass the values ​​received in the WebSocket extension to the site's js function?

Good afternoon! I'm trying to figure out how extensions work in chrome. I wrote a small script, it connects to the server on my computer via WebSocket and receives json. I successfully show the received data on the page of the desired site. But the performance of the site is partially lost. For the full operation of the site, you need to pass my json to a function that is already on the site. How can this be implemented? The network shows examples of working with DOM , I did not find where the extension interacts with the js of the site. Yes, even on the site all the necessary js is written in the body of the site. And when the page is loaded, their json is formed in the same place.
EXAMPLE:

newArr('[{"id":"1","name":"name1"},{"id":"2","name":"name2"},{"id":"3","name":"name3"}]');

function newArr(text){
var data = JSON.parse(text);
for(var itemid in data) {
        console.log(itemid);
      }}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question