Ask coding questions

← Back to all posts
Import js script from github repo using link
ReallyBasic (11)

I am trying to create a modding system for a game I am making using javascript, so I am allowing users to insert a link to a GitHub repo and upload mods in a json format. There is a readme and a mod.js file in each mod, but I only need to read the mod.js file.

What would be the best way to do this?

Thanks, RBG

Answered by Coder100 (18139) [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100 (18139)

all js files are stored in a raw place, you could directly prompt them (or you can generate them) to get that file.

on any file you can click raw

and now all your job to do is to get the URL of that raw file, and use fetch to get the contents!

ReallyBasic (11)

So if they submit a link like this one: https://github.com/User_Name/Mod_Name.git
then how would I be able to get the url to that specific file?
To narrow down what I am looking for, is there a specific method I can write or call?

Thanks for the response!
@Coder100

Coder100 (18139)

hmm
well

you could use regexp replace maybe @ReallyBasic

ReallyBasic (11)

I figured out how to do it with the raw file. Thanks for your help! @Coder100