5

Screenshot / Code Snippet

screenshot of related tags for search

About

Back in May A.Danesh asked "How can I see related tag for a search query?". I didn't actually see this question at the time but by September I started wondering the same thing. In fact I went so far as to post a feature request asking for it: Show “Related Tags” on the “Search Results” page. But then I decided not to be lazy and went ahead and implemented it myself.

You've probably noticed that when you're on the page for any tag (or set of tags), you will see a list of Related Tags in the sidebar on the right. You may have noticed the Search page does not have this feature, yet conceptually it's possible to imagine that there are tags related to search results.

This user script counts all the tags in the search results on the page on the screen and does its best to emulate the Related Tags module as seen in tag pages.

If you click on one of the related tag links, that tag will even be added to the search.

License

I hereby release this script into the public domain. Do what you want with it.

Download

You can download it directly from github:gist: Download

If you are using Firefox with Greasemonkey installed and enabled, you can install it directly by clicking here.

Platform

It's a browser user script so it can be used directly on Google Chrome and opera via their "extensions" menus and pages. On Firefox it requires Greasemonkey.

Contact

You can contact me, Andrew Dunbar, a.k.a. hippietrail via the Travel Stack Exchange chat room, "You Are Here", or just leave a comment or answer right here in StackApps.

Code

It's written in heavily jQuery -ified JavaScript.
Read the code on github.
Make a clone of the code on github.

News

  • Version 0.12 adds an API key (or is it an App key?) so it can now make 10,000 API calls per day instead of 300
  • Version 0.13 moves to a true tf-idf weighting, with a logarithmic function and using the number of questions on the site as a factor
  • Version 0.14 was just a cleanup and refactor after checking with jslint
  • Version 0.15 supports the new elasticsearch backend and layout

1 Answer 1

2

Instead of linking to a .tar.gz archive, don't you think it's more practical to link to the raw file instead so it can be installed immediately?

Click here to install the script

It seems more logical to me.


Also, there is a small problem that you can add tags to your search query multiple times.

If a tag is already in the search query, it should not be displayed in the "related tags" list IMO.

Screenshot

8
  • 1
    Both good points. In Chrome and Opera you can't install directly from a link to a user script any more, but if you can with Firefox then it makes sense. I'm not sure which wording will be best though or what happens in Firefox without Greasemonkey installed. I'll try to sort out the "adding the same tag multiple times" issue. Oct 4, 2012 at 15:39
  • In Firefox with Greasemonkey, a dialog box will pop up asking you if you want to install the script. With Scriptish, the browser will navigate to the page with the script, and then a dialog box will also pop up. Oct 4, 2012 at 15:55
  • If you don't have GM / Scriptish installed, you will simply be presented with the script's source code. Oct 4, 2012 at 15:56
  • Yes I tried Chrome, Opera, and Firefox+Greasemonkey and edited the post. Not as boldly as your suggestion since I didn't want to annoy people that were just going to get the source code rather than an install. Oct 4, 2012 at 15:59
  • By the way, I believe that Tampermonkey and NinjaKit work about the same way as GM / Scriptish. Oct 4, 2012 at 16:00
  • I wonder if there's some way the site could have a smart link which sniffed whether your browser will allow a direct install. What do other userscripts here do? Oct 4, 2012 at 16:02
  • 1
    Also, there is a small problem that you can add tags to your search query multiple times. - I've just fixed this in version 0.7 now on github. Thanks for the report. Oct 4, 2012 at 17:05
  • @hippietrail you can check for the user's 'user-agent' (browser) with for example PHP because that is sent with the headers of an HTTP request. Checking for extensions is probably not possible with only PHP (perhaps a JS hack? I think there could be an SO post on that.).
    – 11684
    Feb 7, 2013 at 7:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .