May
26
2021

Unity Forums Auto Select Current SubForum in Search (GreaseMonkey script)

Someone suggested in the forums that forums search page could auto-select current sub-board.

Tested it quickly with GreaseMonkey and seems to work well, here’s the source:

// ==UserScript==
// @name Unity Forum Search : AutoSelect current board item inside Search select list (based on referrer url)
// @namespace https://unitycoder.com
// @version 1
// @include https://forum.unity.com/search/?type=post
// @grant none
// ==/UserScript==
// more info https://unitycoder.com/blog/2021/05/26/unity-forums-auto-select-current-subforum-in-search-greasemonkey-script/
// get referring board url
if (document.referrer==null) return;
// cleanup ref
var ref = document.referrer;
ref = ref.replace("https://forum.unity.com/forums/","");
// find board name from url
var dotPos = ref.indexOf('.');
if (dotPos==-1) return;
ref = ref.substring(0,dotPos);
// get selection box that contains forum boards
var sel = document.getElementById("ctrl_nodes");
// loop to find match in the select items and url board name
for (var i = 0;i<sel.options.length;i++)
{
var item = sel.options[i].text.trim();
if (item.toLowerCase() == ref.toLowerCase())
{
sel.selectedIndex = i;
break;
}
}

Related topic:
https://forum.unity.com/threads/suggestions-for-the-search-forum-functionality.1115584/

Example gif: I’m inside Platforms / Xiaomi – board, click Search, and Xiaomi gets autoselected


1 Comment + Add Comment

  • This seems like such a little thing, but as often as I find myself searching, it is amazing. I find myself making lots of similar edits, but in Stylus, such as permanently making the forum selection box itself larger, making the forum/posts in general much wider, changing the font on code blocks, etc.

    Glad I am not the only one who spends time doing things like this, lol.

Leave a comment

Connect

Twitter View LinkedIn profile Youtube Youtube Join Discord Twitch Instagram

UnityLauncherPro

Get UnityLauncherPRO and work faster with Unity Projects!
*free unity hub alternative

@unitycoder_com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.