Discussions » Development

Standalone userscript server (proxy)

§
Posted: 2020-06-03

Standalone userscript server (proxy)

Hi there folks :)

I'm looking to deploy a greasemonkey script on the server side in a proxy. This is to make custom changes to a legacy monolithic compiled webapp so internal users can all benefit from the existing script without having to install the addon.

I found monkeygrease https://www.theserverside.com/discussions/thread/37475.html, from 2005 but it's website now seems to be a personal blog: http://www.monkeygrease.org/

Perl offers https://metacpan.org/pod/HTTP::Proxy::GreaseMonkey in CPAN, but it is also legacy (2007).

I considered if it would be possible to run a browser as a proxy, but have not found any documented way to do so.

I considered if it would be possible to run a userscript (greasemonkey, tampermonkey, violentmonkey, etc) as a standalone service, but I'm not sure how to approach this task.

Anyone have any ideas?

wOxxOmMod
§
Posted: 2020-06-03
Edited: 2020-06-03

Userscripts don't work with raw HTML responses, they need DOM and full JavaScript environment for the page and its DOM, they don't run on the server. This whole proxy thing most probably just adds a script tag that contains the userscript's code and a polyfill for GM_* functions. You can write the polyfill yourself and add the tags to the response using any [advanced] proxy software, I guess.

§
Posted: 2020-06-03

Sure, that's an approach that would work. We have a large library of userscripts that I'm trying to avoid rewriting though :(

wOxxOmMod
§
Posted: 2020-06-03

If your polyfill is good you won't need to rewrite the scripts. You can probably find existing GM polyfills (they're written in JavaScript just like userscripts). There'll be a problem with GM_xmlhttpRequest though: you'll probably have to set up an additional service on the proxy server so the gmxhr polyfill would use it to make cross-origin requests.

Deleted user 769488
§
Posted: 2022-04-09

If you work with proxies, it's important to use a good server. For example, suppose you use a shared server on the Internet. In that case, you might violate the provider's terms of service, which would mean that they could refuse your traffic if discovered. Suppose you are working in an office or at home. In that case, it is important to be aware that only your computer will be able to access the Internet from behind your proxy. I would recommend working with a residential proxy online https://soax.com/residential-proxies . Using a proxy can also give you access to certain sites blocked by your ISP.

Post reply

Sign in to post a reply.