1

I am trying to run a JavaScript file I hosted on GitHub.

Its a snow falling script from This Site

This code is not working.

<html>
<head>
<title>DHTML SnowStorm: Basic Example</title>
<script type="text/javascript" src="https://raw.githubusercontent.com/GH0STH4CKER/PROJECTS/master/snowfall.js"></script>
</head>
<body style="background:#6699cc;font:100 1.75em helvetica neue, helvetica,arial,verdana,sans-serif;color:#fff">
<h1 style="font-size:2em;margin:0px;font-weight:100">Example SnowStorm page</h1>
<p>
 A single Javascript reference in the &lt;head&gt; tag is required for SnowStorm to work.
</p>
<p>
 View the source of this page for reference.
</p>

</body>
</html>

Output : No Snow Falling Expected : Snow falling

How can I run this .js file in my website ?

Update - Got this error in console :

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://raw.githubusercontent.com/GH0STH4CKER/PROJECTS/master/snowfall.js with MIME type text/plain.

  • 1
    You are probably getting CORS error but if it's not CORS, please give more detail about what is not working. – Tugay İlik Sep 30 '22 at 08:01
  • 1
    check your browser console for possible errors and post some code that can regenerate the error or the situation that you are stuck in. – Me Bottle O Scrumpy Sep 30 '22 at 08:06
  • 1
    @Tugayİlik i added full code and screenshots – Black_Hoodie Sep 30 '22 at 08:20
  • 1
    @MeBottleOScrumpy Found this `Cross-Origin Read Blocking (CORB) blocked cross-origin response https://raw.githubusercontent.com/GH0STH4CKER/PROJECTS/master/snowfall.js with MIME type text/plain. See https://www.chromestatus.com/feature/5629709824032768 for more details.` – Black_Hoodie Sep 30 '22 at 08:21
  • 1
    perhaps this link might help -------- > [this](https://stackoverflow.com/questions/50873764/cross-origin-read-blocking-corb). it seems the MIME of requested file and received file should match. – Me Bottle O Scrumpy Sep 30 '22 at 08:32

2 Answers2

4
[ ~ ] ➜  curl -I https://raw.githubusercontent.com/GH0STH4CKER/PROJECTS/master/snowfall.js | grep -i Content-Type
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0 21184    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
content-type: text/plain; charset=utf-8

The server you are using, raw.githubusercontent.com, tells the browser that the file contains plain text.

Since it has been told that it isn't JavaScript, the browser doesn't execute it.

Use a hosting service designed for general purpose hosting instead.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • 1
    Technically the code could be executed like `fetch('https://raw.githubusercontent.com/GH0STH4CKER/PROJECTS/master/snowfall.js').then(x => x.text()).then(result => eval(result))`, but the source includes a hijacking prevention snippet – Christian Vincenzo Traina Sep 30 '22 at 08:22
0

This is not possible. You get a CORS (Cross-Origin Resource Sharing) error. This means you cant access the data on another domain.

More info at: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

Maybe try downloading the file and put it in the website folder?

Hope I could help, beldrnl

BeldrNL
  • 53
  • 9
  • There are no CORS restrictions for the `src` attribute of a ` – Quentin Sep 30 '22 at 08:15
  • If there is cross-origin supported file hosting available you can mention them for helping – ghost21blade Sep 30 '22 at 08:59