How to inject JavaScript into WebGUI in my plugin?


Guns McWar

Recommended Posts

Thank you everyone for reading. To the plugin gurus like @Squid, @dlandon, @bonienl, and more, this is probably the easiest Unraid dev question you've ever been asked.

 

TL;DR: How do I inject a simple line of JavaScript into the entire WebGUI?

 

I'm making a simple plugin to change the href of the WebGUI Unraid logo. I'd prefer it link to my server IP rather than the Unraid website. Also, I'd like to learn Unraid development and fill some holes in the plugin documentation for aspiring plugin developers.

 

My plugin page in settings currently reads and writes to a configuration file stored on the boot flash drive. I'd like to take values from the configuration file and include those values in some JavaScript across the whole WebGUI.

 

My plugin structure is:

 

/boot/config/plugins/[plugin name]

  • .cfg file: stores user values

 

usr/local/emhttp/plugins/[plugin name]

  • .page file: retrieves values from config and HTTP posts them to save-settings.php
  • save-settings.php: gets the HTTP post data and writes those values to the config file

 

Any help would be greatly appreciated! I've tried to do this all independently based on existing resources, but I figured it's time to ask. Thank you!

Link to comment

Thank you so much! Great point about the variable names -- mine are very generic. Thank you for all that you do for the community, @Squid

 

If I can ask one last question, does anyone know how get a plugin to appear under Tools > Web GUI? I believe I've tried Menu="WebGUI" on my settings .page, but I didn't see it there. However, it could've been any number of other issues in my early code.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.