8

Userscript to set 'Activity' tab on profile as default tab

When the new profile page design was released, there was a feature request to make 'Activity' the default tab. Because this got declined, I built a userscript that redirects you to the 'Activity' tab if you have not yet manually selected a tab.

0

1 Answer 1

7

The following performs better:

  1. @match is much less resource intensive than regex includes.
  2. Not all platforms support regex includes.
  3. Run at doc start so that don't have to wait for most of the page to load before redirecting.
  4. Use location.replace so that browser history is not filled with junk pages and back button works as expected.
  5. All SE sites are matched. The redirect appears to do no harm on sites that don't have the new profile pages yet.
  6. Runs on Stack Overflow for Teams.
// ==UserScript==
// @name        Stack Exchange, 'Activity' tab as default
// @description A userscript that automatically shows the Activity tab as default on profile pages
// @match       *://*.askubuntu.com/users/*
// @match       *://*.mathoverflow.net/users/*
// @match       *://*.serverfault.com/users/*
// @match       *://*.stackapps.com/users/*
// @match       *://*.stackexchange.com/users/*
// @match       *://*.stackoverflow.com/users/*
// @match       *://*.superuser.com/users/*
// @match       *://*.stackoverflow.com/c/*/users/*
// @exclude     *://*/review
// @exclude     *://api.stackexchange.com/*
// @exclude     *://blog.*.com/*
// @exclude     *://chat.*.com/*
// @exclude     *://data.stackexchange.com/*
// @exclude     *://elections.stackexchange.com/*
// @exclude     *://openid.stackexchange.com/*
// @exclude     *://stackexchange.com/*
// @grant       none
// @run-at      document-start
// @version     2.0
// @history     2.0 Added support for Stack Overflow teams
// @author      ProgramFOX and Brock Adams
// @homepage    https://stackapps.com/q/6267/7653
// ==/UserScript==
/* eslint-disable no-multi-spaces */

if (    ! location.search   &&
        ! location.hash     &&
        ! /^chat\./.test (location.host)    &&
        ! /\/users\/edit\/|\/login\b|\/flag-summary/.test (location.pathname)
) {
    location.replace (location.href + "?tab=topactivity");
}
3
  • Nice, thanks a lot! By the way, what is onstartups? I cannot see anything SE-related there.
    – ProgramFOX
    Apr 18, 2015 at 14:22
  • See answers.onstartups.com . I don't remember if it's future or now defunct. Just that it had to be, or will be supported at one time. Apr 18, 2015 at 14:25
  • 1
    @BrockAdams The site was closed a little over a year ago, but the community took the data dump and revived the site (thus it's not an SE site anymore). See discuss.area51.stackexchange.com/questions/12607/….
    – hichris123
    Apr 18, 2015 at 14:46

You must log in to answer this question.

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