[Forum Modification][Userscript] Personalized Quick Links menu


Kheldarn

 

Posted

Many of us have some forum locations that we visit frequently, and sometimes it can be nice to have easy access to them.

This userscript hijacks the Quick Links nav-menu item, and replaces it with a user-defined list of links.

example:



Userscripts are little snippets of code that can modify pages viewed in your browser. Most modern browsers have some way to run userscripts, but the way to do this varies a bit. Some browsers support them natively, while others require a plugin/extension of some kind.

I'm most familiar with running userscripts in Firefox (with the Greasemonkey addon), so I will give a brief introduction to how to install and modify the script in Firefox/Greasemonkey. The procedure will be similar for other browsers, but some of the details might vary a bit. To gain more information about how to add userscripts for your browser, doing a search (with for instance Google) for ”<browser name> userscripts” is usually a good place to start.

(Hint: Chrome has its own version of Greasemonkey (and also supports userscripts natively), Safari has a plug-in called GreaseKit, Opera supports userscripts natively, and Internet Explorer supports userscripts through a number of plugins, for example Trixie, iMacros and IE7pro)


In order to run this script on Firefox, here's what you need to do:
(Disclaimer: you might not want to do this if you're not comfortable with managing Firefox addons.)


1) Install Greasemonkey.
It can be found here (click "Add to Firefox")
Once installation is complete it will ask you to restart Firefox. Do so.

2) Add the script.
It can be found here (click "Install")



Once you've done this, you'll probably want to change the script so that it uses your own favorite links (that's the entire point of having a personalized Quick Links menu after all). By default it just contains a few examples, and that's rather boring.


To change what items are on the menu, this is what you do:

1) Locate the Greasemonkey icon (monkey icon that's normally in the lower right part of Firefox), right-click it and select "Manage user-scripts...".

2) Select "Quick Link Favorites (CoH)" in the list on the left, and then click the Edit button.

If this is your first time editing a Greasemonkey script, it will ask you to choose a text editor. If you don't have any other preference, you can use Notepad (usually found at C:\Windows\Notepad.exe").





The script should now open in your editor, and you should see something that starts like this:


// ==UserScript==
// @name Quick Link Favorites (CoH)
// @namespace tag:stargazer.coh,2009
// @description Puts the links of your choosing on the Quick Links nav menu item on the City of Heroes forums
// @include http://boards.cityofheroes.com*
// @include http://boards.cityofvillains.com*
// ==/UserScript==



/*Begin user-configuration
-------------------------------*/


//List of item names. Names should be surrounded by "" and separated by ,
var names=["Favorites:",
"Main forums",
"Dev Digest",
"Comm. Digest",
"Miscellaneous:",
"Mark Forums Read",
"Tags",
"Subscribed Threads",
"How to:",
"Use this menu"];

//List of item link targets. Links should be surrounded by "" and separated by ,
var links=["",
"/forumdisplay.php?f=547",
"/forumdisplay.php?f=673",
"/tracker.php?do=showresults&type=community&language =en",
"",
"/forumdisplay.php?do=markread",
"/tags.php",
"/subscription.php",
"",
"/showthread.php?p=2644217"];




//OPTIONAL: selects if an entry should be on a grey background (0) or a blue/red (skin dependant) background (1).
//If a complete list of colors (one color for each entry specified above) is not provided, all entries will use blue/red.
var bg_color =[0, 1, 1, 1, 0, 1, 1, 1, 0, 1];

//OPTIONAL: selects if an entry should act as a link (1) or be a plain text entry (0).
//If a complete list of types (one type for each entry specified above) is not provided, all entries will act as links.
//Plain text entries still need an entry on the links list above, but you can use ""
var is_link = [0, 1, 1, 1, 0, 1, 1, 1, 0, 1];



/*-------------------------------
End user-configuration*/





You can skip past the first part, all you need to bother with is the yellow part.

The first thing you have to change is the list of item names (starting with "var names=[" and ending with "];"). This is a list of the item names that will appear on your Quick List menu. Each name should be contained within "", and separated by commas. e.g. "Main Forum".

After this is the list of item link targets. These specify what link should be targeted when you click each item on the menu. These should also be contained within "", and separated by commas. e.g "/forumdisplay.php?f=547". You can link to just about anything that can be accessed by links, forum listings/threads/posts/profiles/...., your grandmother's recipe for apple pie, ...
Each name entry will need a corresponding name in the links list. The first name will link to the first link, the 3rd name will link to the 3rd link, and so on.

Tip: If the link is to a page on the CoH forums, you can omit "http://boards.cityofheroes.com" and "http://boards.cityofvillains.com" from the links. Something like "/forumdisplay.php?f=547" will then lead to "http://boards.cityofheroes.com/forumdisplay.php?f=547" if you're currently using the hero forums, and "http://boards.cityofvillains.com/forumdisplay.php?f=547" if you're currently using the villain forums.

Tip: Use forumdisplay.php and showthread.php to link to favorite subforums and threads.


Tip; How to link to posts by a given user:
"/search.php?do=finduser&u=337363"

Adding the above link to your Quick Links menu will lead to all posts by user number <number>, i.e. me. That's probably not very useful to most, but maybe there's another user for which you'd like to have an easy way to find their posts. Maybe there's a particular dev you want to keep a closer eye or, or maybe you have a friend you'd like to follow. This way you could have your very own Castle digest.

All you need to do is to change the number <number> above to the user id of the person you want to follow. To find someone's user id, you can find one of their posts and then hover your mouse over their name. The user id will be displayed in the link that's shown in your status bar.


Tip; How to link to a search for a given term:
"/search.php?do=process&query=stargazer&showposts=1"

Adding the above link to your Quick Links menu will lead to a search for the search term ”stargazer”. This can be a convenient way to perform a ”vanity search”, and will show posts mentioning you by name, as well as posts quoting your posts (as long as the ”Originally posted by:” part isn't removed). In my case it has also proven to be a good way to find threads discussing Star Trek Online...

You can of course also use this to search for other things you might be interested in, such as discussions about specific topics.

To use this, simply change ”stargazer” in the link above to whatever search term you want to use.




If you want to further customize your Quick Links menu, you can look at the optional orange part above.


For each entry you have the option of using a grey background, or a blue/red background (depending on your current skin). This is handled by the bg_color list. To make an entry use the grey background, its value should be 0, and to use the blue/red background the value should be 1. Again, each value will be associated to its corresponding names entry. The first entry sets the color of the first menu item, and so on.
If the number of items on the color list does not match the number of menu item names, all entries will use the blue/red background. This is what makes the setting optional, but it also has the side-effect that if your Quick Links menu has exactly 10 entries, it will use the pre-defined color settings of the default example menu. Adding or removing a vale will take care of this.


Next is the option to make an entry work as a link or not. This is handled through the is_link list, and a value of 1 means that the entry will work as a link, and a value of 0 that it will not (it'll just display the name of the entry, which can be good for naming different parts of the menu). This time, if the number of items on the is_link list does not match the number of menu item names, all entries will act as links. This is what makes the setting optional here too, but it again has the side-effect that if your Quick Links menu has exactly 10 entries, it will use the pre-defined link/not-link settings of the default example menu. Adding or removing a vale will take care of this.

The default menu uses a grey background for all labels, and a blue/red background for all links.


Knowing this, we can look at what the default example menu will look like.

1: A text label of "Favorites:" on a grey background.
2: A link named "Main Forums" on a blue/red background, leading to the English sub-forum.
3: A link named "Dev Digest" on a blue/red background, leading to the Dev Digest.
4: A link named "Comm. Digest" on a blue/red background, leading to the Community Digest (filtering out non-English posts).
5: A text label of "Miscellaneous:" on a grey background.
6: A link named "Mark Forums Read" on a blue/red background, marking all forums as read (from the original Quick Links menu).
7: A link named "Tags" on a blue/red background, leading to the forum Tags page.
8: A link named "Subscribed Threads" on a blue/red background, leading to your subscribed threads (from the original Quick Links menu).
9: A text label of "How to use:" on a grey background.
10: A link named "This menu" on a blue/red background, leading to this page.

As you can see that's also what's shown in the image above.



If you want to temporarily disable the script you can right-click the Greasemonkey icon (while on the forums) and unselect it from the list of active scripts (this helps if you want to look at the original Quick Links menu to copy things from it). You can also disable or remove the script from the Greasemonkey "Manage user-scripts" window used above.


Should you make an error in the editing (e.g. mismatches with ",;[] etc.) the script will simply fail to run, and you'll get the original Quick Links menu.


Hopefully that wasn't *too* complicted.


If you want to, you can use images in the item names too, with <img src=\"path to image\"> (it's important that you use \" instead of " to surround the image path).




Edit: In addition to images, you can also use other HTML code in the item names. For instance, you can center text by using <center>Item Name</center> (or <div align=center>Item Name</div>), or bold it by using <b>Item Name</b>. You could also change the font type/size/color, or pretty much anything you can do with HTML code. Just remember to use \" instead of " when inputing the item names into the userscript.


 

Posted

Quote:
Originally Posted by Kheldarn View Post
That's a very nice example of a customized Quick Links menu. I think I'll actually borrow the centered "section titles" for my personal menu. I won't use it in the default menu since I want to keep it as simple as possible, but I should probably mention how to do it in case people want to use it. In fact, I think I'll edit that into the original post...