Programming Question on Replays

Hello, I'm beginning a project to edit replay files. I'm 'hacking' the replay viewer to add some additional functionalities.
Its a short question that would probably be better suited for a simple question simple answer thread but I can't seem to find one.
Right now, I'm running into some trouble with this line in replay files:
Code:
let daily = Math.floor(Date.now()/1000/60/60/24);document.write('<script src="https://play.pokemonshowdown.com/js/replay-embed.js?version'+daily+'"></'+'script>')
I wanted to host the replay-embed.js file somewhere else so I would be able to edit it.
heres what I tried to do:
Code:
document.write('<script src="https://raw.githubusercontent.com/iwa-yasu/showdown_replay_editor/main/replay_embed.js"></'+'script>');
The two files are identical, and as far as I understand, the file I host on github should still be able to get its dependencies from play.pokemonshowdown/js.
However, this does not work. The replay window just doesn't show up.
I have attached a html file and you can edit this line to confirm this behavior.
On another note, I tried messing with it and found out that
Code:
document.write('<script src="https://play.pokemonshowdown.com/js/replay-embed.js"></script>');
does not work (ridding the '+' part), while
Code:
document.write('<script src="https://play.pokemonshowdown.com/js/replay-embed.js"></'+'script>');
does works.
I really don't understand whats the logic behind this.
I'm not familiar with html and js, so if there's a simple answer to this, >_<

(zipped html file attached as html files are not allowed)
 

Attachments

I'm leaving this here in case anyone else comes across the same problem. Nice and smart user Yoda2798 answered my qn in a discord pm.
If you open the console on the page (ctrl+shift+j or right click -> inspect element, then open the console from there) you can see the error, which is a MIME mismatch, which looking up means that the raw github page you link to basically says "this is a text page" instead of "this is a js file" as far as I can tell. Looking at this https://stackoverflow.com/questions...nal-javascript-file-hosted-on-github#18049842 apparently you can change the url using jsdelivr to work but trying that hasn't worked for me. Although I was thinking, shouldn't the html just be part of your project/directory anyways? Then you could run your js file as something like src="/js/yourfile.js" rather than needing to grab it externally from the web.
 
Last edited:

Users Who Are Viewing This Thread (Users: 1, Guests: 0)

Top