I have a JS array in the "background.js" file of my Chrome extension. I converted the JS object to a JSON string to pass it into the "content.js" file but am unable to do so.
Can I be helped with the code to send the JSON object from the "background.js" file and the code to receive the same from the "content.js" file.
// This is the important portion of the code present in the background.js file.
console.log("Inside the buttonClicked function");
var titles = [];
var hrefs = [];
var links = document.getElementsByClassName('uqZtlf x0HGk QRiHXd MymH0d maXJsd');
for (var i = 0; i < links.length; i++)
{
hrefs.push(links[i].href); // capturing urls
titles.push(links[i].title); // capturing titles
}
jsonObjectLinks = JSON.stringify(hrefs); // converting the js object to the JSON string
console.log(jsonObjectLinks);
var jsonObjectTitles = JSON.stringify(titles);
// I now wish to pass on the jsonObjectTitles to the content.js file
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…