I am creating a chrome extension that allows you to download the JSON displayed on a production logging website. Each of the logs provide an ace editor to display the JSON (this means N number of ace editors for N number of logs, not sure if specific editor selection via jquery is a problem). The intended functionality is to retrieve the contents of the existing ace editor, create a json file, and then download it to disk.
I have added the ace editor API to my chrome extension under content scripts but it seems to be breaking the existing ace editor on the page.
How the editor is normally supposed to look
The ace editor on the webpage before the "Download" button is clicked
The ace editor on the webpage after the "Download" button is clicked
The function that is called when "Download" is clicked:
function initiateJsonDownload(event) {
let data = event.data.jsonTable;
// location of the editor on the page.
let jsonContainer = data.find('.doc-viewer-content > render-directive > div')[0];
// selection of editor specific to current log
let editor = ace.edit(jsonContainer);
// returns undefined
console.log(editor.selectAll());
}
manifest.json:
{
"name": "Log Downloader",
"version": "1.0",
"description": "Allow users to download logs straight to device",
"manifest_version": 2,
"content_scripts": [{
"js": ["thirdParty/node_modules/jquery/dist/jquery.min.js", "selectLogs.js", "thirdParty/ace_editor/ace.js"],
"run_at": "document_end",
"matches": ["https://log-website/*"]
}],
"background":
{
"scripts": ["thirdParty/node_modules/jquery/dist/jquery.min.js"]
}
}