How to (If possible) make a function inside a chrome extension that rewrites a file?
Files in directory : manifest.json background.js ls.txt (background.js obviously always running when chrome is open, in the background)
Example: a function that writes text to a file when the user makes any request
chrome.webRequest.onBeforeRequest.addListener(details => {
const anytext = "anytext"
const filedir = "ls.txt"
//how do I delete everything from ls.txt and write "anytext" to ls.txt, simply, how do I overwrite ls.txt?
},{ urls: ["<all_urls>"] },['requestBody']);
Boring backstory: I've tried looking for this online, but every result either shows me how to download a file or how to read it, maybe there is no way to modify a file? But then how do I save personal configurations between computer reboots if I can't save them to local files? And for anyone asking, this is definitely not why I'm making the plugin, I used this code as an example and not to make a plugin that writes text to a file every time a user makes a request.