There should be a separate build wrapping userscript into a chromium/webextensions add-on.
Basically, the userscript code should be executed in a context of a web page. Something like this:
content-script.js
var userscriptCode = getUserscriptCode();
var script = document.createElement('script');
script.innerText = userscriptCode;
document.rootElement.appendChild(script);
// Remove it once it has finished its work
document.rootElement.removeChild(script);
GM_ functions should be replaced with your own implementations.
There should be a separate build wrapping userscript into a chromium/webextensions add-on.
Basically, the userscript code should be executed in a context of a web page. Something like this:
GM_
functions should be replaced with your own implementations.