Page 1 of 1

Search buttons userscript

Posted: Mon May 20, 2019 11:08 am
by Faeryn
Hello everyone!

I made a userscript that adds "Your posts", "New posts" and "Unread posts" limited to only the currently viewed forum.
So for example when you are in Community General and click the newly appeared "Current forum: New posts", it will show new posts only in Community General and not globally.

You will need a browser plugin called Greasemonkey or Tampermonkey to run these.
Once you have one of them installed, you can create a new script and paste the contents of the script, then save.

It looks like this:
Image

Code: Select all

// ==UserScript==
// @name      BGTSCC better search
// @version   1.0.0
// @author    Faeryn
// @include	  https://bgtscc.net/viewforum.php?f=*
// @grant     none
// ==/UserScript==

function addSearchLink(parent, title, searchId, id, icon) {
  var forum = new URL(document.URL).searchParams.get("f");
  var link = document.createElement('li');
  link.classList.add("right");
  link.innerHTML = '<a id="'+id+'" href="./search.php?search_id='+searchId+'&fid[]='+forum+'"><i class="icon '+icon+'"></i> '+title+'</a>';
  parent.appendChild(link);
}

(function() {
    'use strict';

    if (!document.getElementById("currentForumSearch")) {
        var navBar = document.querySelector('.sub-nav');
        var secondRow = document.createElement('ul');
        secondRow.id="currentForumSearch";
        navBar.appendChild(secondRow);
        addSearchLink(secondRow, "Unread posts", "unreadposts", "unreadPostsCurrent", "fa-info-circle");
        addSearchLink(secondRow, "New posts", "newposts", "newPostsCurrent", "fa-exclamation-circle");
        addSearchLink(secondRow, "Your posts", "egosearch", "yourPostsCurrent", "fa-user-circle");
        var label = document.createElement('li');
        label.classList.add("right");
        label.innerHTML = '<b>Current forum:</b>';
        secondRow.appendChild(label);
    }
})();

Re: Search buttons userscript

Posted: Mon May 20, 2019 11:16 am
by Zanniej
Nice!

If this is something a lot of people want, I can look to integrate this into the forum itself, so you don't have to use external plugins.

Let me know what you guys think!

Re: Search buttons userscript

Posted: Mon May 20, 2019 11:17 am
by Steve
Awesome.

Do you think your script would work for Private Messages as well?

Re: Search buttons userscript

Posted: Mon May 20, 2019 11:18 am
by Zanniej
Steve wrote: Mon May 20, 2019 11:17 am Awesome.

Do you think your script would work for Private Messages as well?
What exactly would you want it to do there? :think:

Re: Search buttons userscript

Posted: Mon May 20, 2019 12:34 pm
by Glowfire
It would be nice to be able to search for keywords in PMs, or type in at least usernames. It's timeconsuming to search through pages for a name as you can basically only sort it after a-z and by date.

Re: Search buttons userscript

Posted: Mon May 20, 2019 1:16 pm
by Planehopper
I like it. Would be useful as a player and as a mod.

A PM search tool by keyword would be flippin amazing. Searching by username to/from would be helpful as well.

Re: Search buttons userscript

Posted: Mon May 20, 2019 2:23 pm
by Steve
Glowfire wrote: Mon May 20, 2019 12:34 pm It would be nice to be able to search for keywords in PMs, or type in at least usernames. It's timeconsuming to search through pages for a name as you can basically only sort it after a-z and by date.
Hey Z-man: This ^^.

Re: Search buttons userscript

Posted: Sun Jun 02, 2019 10:51 am
by tankteddy
:shock: :shock: :o :o YAY!!! THANK YOU!