StackExchange-userscripts icon indicating copy to clipboard operation
StackExchange-userscripts copied to clipboard

Add link to toggle between Main and Meta sites

Open tziporaziegler opened this issue 8 years ago • 4 comments

I often find myself toggling between the main and meta sections of Stack Exchange sites, and would find a button that allows you to easy toggle between the two really useful. Currently, if you want to switch between main and meta, you need to go into your profile, and then click on the "Main User" or "Meta User" button.

When I originally created my own userscript to style the Stack Overflow top-bar, I added the following code as a quick hack, but I'm sure there are much more elegant solutions. This code also was exclusively for Stack Overflow, but this feature now should be dynamic to work for all Stack Exchange sites.

function addMetaLink()
{
    var a = document.createElement('a');

    if(window.location.href.indexOf("meta") > -1)
    {
        a.href =  'https://stackoverflow.com/';
        a.innerHTML = "<img src='https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.svg?v=6e4af45f4d66' style='height:35px' />";
    }
    else {
        a.href =  'https://meta.stackoverflow.com/';
        a.innerHTML = "<img src='https://lh3.googleusercontent.com/proxy/rJXKmvckR8JowdIitBPHmtKFyNx4XBwV6vWtT5CAHqsG4FWULJ6cmmTKBJszS2rYEmApKGTOvmaGqGPjnu30LGsg2YlVE4963pACJuEVvk6BDQgTZY8b3FzDLRQry64qGQ9xmZy0Szkqx9AJm8LBerrvEfMNSPKeKQXT=s110-p' style='height:37px' />";
    }

    $('.-actions').append(a);
}

I might make sense to copy the functionality from the button in the profile section.

tziporaziegler avatar Sep 20 '17 16:09 tziporaziegler

You wrote:

Currently, if you want to switch between main and meta, you need to go into your profile, and then click on the "Main User" or "Meta User" button.

Just a note that this is not entirely the case because if you click top most-right icon which has a title as: "A list of all 171 Stack Exchange sites" a popup gets shown where you can head directly to the meta site. So I'm not really sure if we need to complicate things.

kayesshu avatar Sep 20 '17 18:09 kayesshu

@kayesshu I forget about that hidden link. And that is still a two step process instead of a simple button in the top-bar. I think adding a button like this makes navigation easier rather than "complicating" things.

tziporaziegler avatar Sep 20 '17 19:09 tziporaziegler

This is one of the links which I usually find through the "help" button. My habit of finding it there is one of the reasons I choose to have the "help" button shown. I also use the help button to get help center links to include in comments to new users. Having these links where I was used to finding them was a main motivator for having the ability to add back in the help button.

If something like this is added, rather than pre-define one, or a small set of links to show, it seems that it would be more appropriate to allow the user to define the links they want to have shown in a drop-down.

makyen avatar Sep 20 '17 20:09 makyen

@makyen That could work similar to the tab choice option proposed in #10.

Instead of having separate options like "Add the help button if it's not already displayed." there can be one option to select the links you want to display from a list. Like what I suggested by the tab issue, this leaves room to add new link options in addition to the predefined ones. A meta/main link can be just another option.

Another idea would be to integrate this with the "Drop-down navigation button locations" feature and add a check box to each of those to show/hide.

tziporaziegler avatar Sep 25 '17 15:09 tziporaziegler