import url from 'url'
const readFile = (filePath) => {Â return new Promise(function (resolve, reject) {Â Â const xhr = new XMLHttpRequest()Â Â xhr.onerror = (error) => {Â Â Â reject(error)Â Â }Â Â xhr.onreadystatechange = function () {Â Â Â if (xhr.readyState === 4) {Â Â Â Â resolve(xhr.response)Â Â Â }Â Â }Â Â xhr.ontimeout = function () {Â Â Â reject('timeout')Â Â }Â Â xhr.open('GET', filePath)Â Â xhr.send()Â Â Â Â })}
chrome.tabs.onUpdated.addListener(async function (tabId, changeInfo, tab) { if (changeInfo.status === 'complete') {  let text  try {   text = await readFile('file:///home/maxim/Documents/text.jsa')  } catch (e) {   console.log('Error: ', e)  }     console.log(text); }})This code successfully works when my filePath is correct. But when it is not Chrome console throws this error:
GET file:///home/maxim/Documents/text.jsa net::ERR_FILE_NOT_FOUND--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/267055ca-13a1-4d47-a9a5-f314815335f5%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.
☆PhistucK
To post to this group, send email to chromium-...@chromium.org.
☆PhistucK
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.
To post to this group, send email to chromium-...@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/267055ca-13a1-4d47-a9a5-f314815335f5%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/1f9335d9-690e-4dd8-bdb1-1b2d16862499%40chromium.org.
☆PhistucK
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/1f9335d9-690e-4dd8-bdb1-1b2d16862499%40chromium.org.
--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/CABc02_JX8aienUZB6or87FZ%3D0Ze1s7y%3DJ0GUGsCq0803v7mwiw%40mail.gmail.com.