Global Custom JS

Hey,
im just creating my first nextcloud app where im trying to change the tokens of shared files. For that I need to “inject” my code into the Files App, because the way I thought it would be good is to make it appear in the sidebar panel thingy that appears when you click on the button to share your file/folder. What i tried is this, because I saw that in the docs, but it doesnt work (script does not appear anywhere) when i put it in my index File where the Template Structure and the other includes of js/css are defined:

$eventDispatcher = \OC::$server->getEventDispatcher();
$eventDispatcher->addListener(‘OCA\Files::loadAdditionalScripts’, function() {
script(‘customshare’, ‘app_files/script’);
});

Anyone got an idea or some working code for that? Or is the only way to edit other files and inject your own code by overwriting.

My Nextcloud Version is 21 alpha, cloned from github.

Maybe you can get some inspiration from the JsLoader app which does exactly this?

That worked.
For everyone that wants to know, I just copied and changed appinfo/app.php, the script route and the controller and now everything works like a charm.

1 Like