Skip to main content
3 of 5
onstartups no longer needs to be supported.
Brock Adams
  • 13k
  • 5
  • 39
  • 64

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.
// ==UserScript==
// @name        '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/*
// @grant       none
// @run-at      document-start
// ==/UserScript==

if (! location.search  &&  ! location.hash  &&  ! /\/users\/edit\//i.test (location.pathname) ) {
    location.replace (location.href + "?tab=topactivity");
}
Brock Adams
  • 13k
  • 5
  • 39
  • 64