I want to get to a web page, extract the information I need and then write it in a text file and download it. I couldn't find a way to download or copy the text.
I made an extension which can download text in the popup script, and has the text I need in the content script but how to I connect them both?
content script:
let wordsList = [];
let meaningList = [];
let words = document.querySelectorAll(".status-m > div.word, .status-n > div.word");
let meaning = document.querySelectorAll(".status-m > div.meaning, .status-n > div.meaning");
wordsList = [...words];
wordsList = wordsList.map(word => word.innerHTML)
meaningList = [...meaning];
meaningList = meaningList.map(word => word.innerHTML)
let obj = {}
for(let i = 0; i< wordsList.length; i++){
obj[wordsList[i]] = meaningList[i]
}
console.log(obj)
popup script:
$(function(){
$('.btn').click(function(){
const blob = new Blob(['text to download'],
{ type: "text/plain; charset=utf-8" });
saveAs(blob, "static.txt");
})
})