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.

5
  • 1
    You are probably getting CORS error but if it's not CORS, please give more detail about what is not working. Commented Sep 30, 2022 at 8: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. Commented Sep 30, 2022 at 8:06
  • 1
    @Tugayİlik i added full code and screenshots Commented Sep 30, 2022 at 8: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. Commented Sep 30, 2022 at 8:21
  • 1
    perhaps this link might help -------- > this. it seems the MIME of requested file and received file should match. Commented Sep 30, 2022 at 8:32

2 Answers 2

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.

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

1 Comment

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
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

2 Comments

There are no CORS restrictions for the src attribute of a <script> element unless you include the crossorigin attribute (which the OP isn't).
If there is cross-origin supported file hosting available you can mention them for helping

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.