Is it possible to read/write to a file using Javascript? [duplicate] - javascript

This question already has answers here:
Using Node.JS, how do I read a JSON file into (server) memory?
(13 answers)
Closed 2 years ago.
This is not for a browser.
I intend to make a "blacklist" array for my bot, which will prevent users from running commands. However, I can only seem to do this on the actual bot file as I haven't found a way to do an external method.
What I'd want to do is have my main bot file as normal, but have a blacklist.txt with an array including their username, discord account ID and extra notes which can be accessed at any time by admins using a command.
This is what I'm using:
var blacklist=[
{username:'',userid:'',notes:''},
]

It's possible with node.js(a platform based on javascript)
Here is an example how to do that Using Node.JS, how do I read a JSON file into (server) memory?

Related

Simplest way to store this to do list data even after browser closed? [duplicate]

This question already has answers here:
How to store objects in HTML5 localStorage/sessionStorage
(24 answers)
Storing JSON data in browser memory
(3 answers)
Closed 4 years ago.
I want to make a web-based TO-DO list exactly like the one on the W3schools link below, however when I close the browser all the inputs and edit disappear and it reverts back to the original. Is it possible to easily store the values (if not I will quickly delete this Q)? What code can I add to make it save the data (perhaps localstorage?) each time or would I have to set up a php/mySql? No authentication required, whatever is the most straightforward way to do it.
The exact code is below. I prefer to host locally for simplicty but if necessary web based hosting server is also fine with me.
To Do List Example from W3 Schools
You can use Javascript LocalStorage to save data on browser close, only if it is being loaded on a domain that is accessed via HTTP.
Though, you can use a server-side database, such as mySQL to store data.

read local text file in javascript [duplicate]

This question already has answers here:
How do I read in a local text file with javascript?
(2 answers)
Closed 9 years ago.
I have a local test.txt file that I need to read into variable in JavaScript and send that variable to google.visualization.arrayToDataTable() to create a chart. Text in test.txt file is in right format (I tried to copy it directly into function and it works). But I don't know how to read that file into variable.
Reading local fine js is not permitted how ever you can use jQuery script function to load the data

Encrypt javascript file [duplicate]

This question already has answers here:
How can I hide or encrypt JavaScript code? [duplicate]
(7 answers)
Closed 4 years ago.
I don't find any info about that,so asking here.
Is somebody ever used some tool to protect javascript files? And totaly encrypt them?
Because I found this tool that seems like can totaly encrypt JS?
What do you think?
http://webtools.securitygeeks.net/p/blog-page_26.html?
That tool is useless. It declares a global variable called teksasli which contains your original script in a plain string. just look at the value of that variable in any console to see the original source.
There is no point in trying to encrypt Javascript, because the user/browser needs to decrypt it in order to run it.
If you want to obfuscate the source code, You could try GWT http://mojo.codehaus.org/gwt-maven-plugin/ (The Google Web Toolkit ).

How to find client's IP Address using Javascript code [duplicate]

This question already has answers here:
How to get client's IP address using JavaScript? [closed]
(31 answers)
Closed 9 years ago.
I want to find client's IP Address when accessing my app..How to find using javascript code..kindly provide help with sample code..I tried wit tis code but m not getting
function getip(json){
alert(json.ip); // alerts the ip address
}
You can't using ONLY JavaScript on it's own. You need to use a server side script ans call it using Ajax to perform this task.
For example in PHP script, you can do the following to get the client's ip address:
echo $_SERVER["REMOTE_ADDR"];
Next call this script using Ajax and display/use it in your page.
At least there used to be a way using Java to do this, but Javascript alone cannot find a machines IP.

How to avoid displaying "C:fakepath" in browsers [duplicate]

This question already has answers here:
How to resolve the C:\fakepath?
(13 answers)
Closed 9 years ago.
How to avoid displaying "C:fakepath" while file uploading. While uploading the file javacript method is called to set the selected path im my case
This is a browser security feature that is implemented.
According to the specifications of HTML5, a file upload control should not reveal the real local path to the file you have selected, if you manipulate its value string with JavaScript. Instead, the string that is returned by the script, which handles the file information is c:\fakepath.
If you still want to get rid of this fakepath you may check out this site
How To Get Rid of C:\FakePath in IE When Uploading A File to the Website
Hope it helps.

Categories

Resources