I am trying to make an chrome-extension. But i have a trouble with returning values out of callback function. Here is my codes; content.js
let filename="block.jpg";
let imgs = document.getElementsByTagName('img');
function iletisim(callback, web_adr){
chrome.runtime.sendMessage({text: web_adr}, function(response) {
callback(response);
});
}
function gonder_al(param1){
console.log("gonder_al ",param1);
}
for (imgElt of imgs){
iletisim(gonder_al, imgElt.src);
let url = chrome.extension.getURL(filename);
imgElt.src=url;
};
I want to replace images on the web page under some conditions, which are background.js sends. On this code need to use the callback(response)
under the for loop? It seems not possible with sync callback functions but i am not familiar with with java async functions.