How to run a remote JavaScript stored in a GitHub account, on a user script manager?

Let’s say I have a file named a.js with the following content:

alert('Hi');

I even have a raw link of it:

How could I run this remote code situated on the GitHub cloud, right here on my local computer with a userscript manager?

sounds like a recipe for malware infection if you ask me…

You could inject a script tag into the HTML with it’s source set to the target file and the async property set?

1 Like

I should add, I want to call only remote scripts that I have created myself on my GitHub account.

So why do you want that? It makes absolute no sense.

I mean, I can understand it as a sort of cross-device versioning tool; if you update the script, all your devices would start using it, because your local script is effectively just a bootloader/injector that shouldnt change often/at all.

It’s still not… exceedingly secure, because you’re hosting your code publicly, and theoretically others would be able to modify it without you knowing. But that’s an option.

What is the difference to hosting on the web server itself?

I assume he’s injecting a script into a site he does not himself control.

To me it does and I’ll gladly explain :slight_smile:

I have several computers and I don’t want to manually clone a simple, generic and very general script I wrote and store in my GitHub account.

It’s a script that just block things like news websites, autoplaying of videos, etc.

I just want to upgrade it from one place and not from five places, if at all there is anything to update.

@m_hutley

Follow up thread here in SitePoint:

How to execute an appended script in vanilla JavaScript?