Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to inject JavaScript into WebGUI in my plugin?

Featured Replies

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!

If you have a "settings" .page file, then you need to create another .page that'll inject the code

 

Menu='Buttons'
Link='nav-user'
---
<?
.
.
.
?>
<script>
  .
  .
  .
</script>

 

Oh, and forgot to mention.  Ensure that any and all variables, elements etc are 100% unique and not a generic naming so as to not interfere with any thing else now or in the future, or with any random plugin installed

  • Author

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.

6 minutes ago, Guns McWar said:

Menu="WebGUI"

That's how you want it.

  • Author

Wow, thanks again!

  • Author
21 hours ago, Squid said:

That's how you want it.

Just following up in case someone else has this question: Menu="WebGui" works, but Menu="WebGUI" does not.

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.