Search buttons userscript

Suggestions for Improving or Enhancing the Forums

Moderators: Moderator, Quality Control, Developer, DM

Post Reply
User avatar
Faeryn
Retired Staff
Posts: 17
Joined: Sun Oct 28, 2018 6:09 am

Search buttons userscript

Unread post 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);
    }
})();
User avatar
Zanniej
Posts: 2454
Joined: Sat Jan 11, 2014 11:28 am
Location: The dark parts of the forum

Re: Search buttons userscript

Unread post 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!
Off to greener pastures
User avatar
Steve
Recognized Donor
Posts: 8127
Joined: Wed Jul 08, 2015 5:42 am
Location: Paradise in GMT +1

Re: Search buttons userscript

Unread post by Steve »

Awesome.

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

Talsorian the Conjuransmuter - The (someTIMEs) Traveler

The half-MAN, the MYrchanT(H), the LEGENDermaine ~ Jon Smythe [Bio]

Brinn Essebrenanath — Volamtar, seeking wisdom within the earth dream [Bio]
User avatar
Zanniej
Posts: 2454
Joined: Sat Jan 11, 2014 11:28 am
Location: The dark parts of the forum

Re: Search buttons userscript

Unread post 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:
Off to greener pastures
User avatar
Glowfire
Posts: 1814
Joined: Thu Jul 28, 2016 9:14 am

Re: Search buttons userscript

Unread post 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.
Power is the most persuasive rhetoric.
Friedrich von Schiller
User avatar
Planehopper
Posts: 2298
Joined: Sun Oct 09, 2011 4:50 pm

Re: Search buttons userscript

Unread post 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.
User avatar
Steve
Recognized Donor
Posts: 8127
Joined: Wed Jul 08, 2015 5:42 am
Location: Paradise in GMT +1

Re: Search buttons userscript

Unread post 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 ^^.

Talsorian the Conjuransmuter - The (someTIMEs) Traveler

The half-MAN, the MYrchanT(H), the LEGENDermaine ~ Jon Smythe [Bio]

Brinn Essebrenanath — Volamtar, seeking wisdom within the earth dream [Bio]
User avatar
tankteddy
Posts: 424
Joined: Wed Jul 06, 2011 7:45 am
Location: NV-USA

Re: Search buttons userscript

Unread post by tankteddy »

:shock: :shock: :o :o YAY!!! THANK YOU!
Theodar Battleforge: "Oi! What dis do?" *BOOM*
Thar Kogan "A har Thar!"
Nevarra Stayanoga "A wolf will always be a wolf."
Post Reply

Return to “Forums”