0

I'm using a javascript scripting engine for a MUD i'm playing, they have a javascript client hosted on their server. I'm wanting to store some information in a database and access it from the client (or inject it somehow into the client) but I'm not seeing how I could do that.

Basically I can write javascript files into the trigger section of the website and they fire. It has Javascript and JQuery options. It does not have a database option on their end, which is why I'm trying to add it myself.

I know client side javascript has a lot of restrictions on it, so I'm not sure how far I could really go with this.

4
  • 2
    Is it website or NodeJS what you executing JavaScript on? Commented Jul 26, 2017 at 17:47
  • Do you want to store data client based, for each client individually, or do you need to common storage that is shared between the clients? For client based storage you can use localStorage, if you need shared data then you need a host where a database is running, and some kind of interface to access the data like REST. Commented Jul 26, 2017 at 17:54
  • @lilezek It's a website that accepts javascript code to pull events, the client itself is made in HTML5 play.achaea.com Commented Jul 26, 2017 at 20:21
  • @t.niese I'm mostly wanting to store a database on my end and let the website access it so I can store more information. I can already trigger my own javascript into the website through their settings area, I'm just trying to also include a local database Commented Jul 26, 2017 at 20:23

1 Answer 1

1

I think you might be able to do this, but it's going to be hacky.

If you're able to attach a script node to the dom, you can trigger GET requests with no origin restrictions wherever you want. You would do that to your own backend.

You would have to throw away all good practices and use GET requests with a lot of query params so send data to that (your) backend.

You would have to write the backend so that it does whatever you want with the data, e.g. store it in the db.

You would have to make sure you return valid js to the client, even if it's only to dismiss it.

Alternatively...

you could load an iframe to a site you control, and change the iframe src with the data, and then do with the data whatever you want (like sending it to some bakcend of yours properly) in your site (that's loaded in the iframe) by detecting changes in the url...

Sign up to request clarification or add additional context in comments.

1 Comment

I'm okay with the code being a little hacky. It's not for public use, and it's only loaded behind my own username and password on the website itself. And thanks for these ideas

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.