7

About

Inspired by the reaction to Beta release of Collectives™ on Stack Overflow, I decided to create a small practical solution in the form of a user script.

It will remove almost all traces of Collectives™ on Stack Overflow:

  • Tag-icons on posts.
  • Award icons & small orange affiliation banner on user cards on posts.
  • Box under the user avatar on user profiles.
  • Box in the home page right sidebar.
  • Answer endorsements ("Answer recommended by ...").

The exception is to the Collectives™ link in the left sidebar and the Collectives™ themselves. I wanted to keep this so that one can still go there and read about them.

Platform

Should work with any user script manager & any browser running JavaScript.
Tested (mostly by 10 Rep) on Windows 10 using

  • Opera, Chrome & Edge with TamperMonkey.
  • Firefox with ViolentMonkey.

Contact

For bugs, please post here. Comments are fine too.

Code

Vanilla JavaScript:

// ==UserScript==
// @name         Stack Collectives Off
// @namespace    scratte-fiddlings
// @version      0.2
// @description  Pretending Collectives don't exist
// @author       Scratte (stackoverflow.com/users/12695027)
// @include      https://stackoverflow.com/*
// @exclude      https://stackoverflow.com/collectives*
// @grant        none
// ==/UserScript==

// NOTE: The script does not remove the "Explore Collectives" on the left sidebar.
//       It's still possible to go to a collectives site and check them out.

(function() {
    'use strict';

    // Suggested by Oleg Valter (https://stackoverflow.com/users/11407695)
    // https://chat.stackoverflow.com/transcript/message/52657173#52657173
    const mostCollectivesStuff =
              [
                  // the collective on the home page right sidebar
                  ".js-join-leave-container",
                  // both 1: the collective icons from posts on the home page
                  //      2: the award icons from user cards on posts
                  "a[href*=collectives]:not(#nav-collective-discover):not(.s-card)",
                  // the particular collective in the sidebar on posts
                  ".sidebar-subcommunity",
                  //  orange affiliation banner from user profiles on posts
                  ".affiliate-badge",
                  // "Answer recommended by ..."
                  ".js-endorsements"
              ];

    document.querySelectorAll(mostCollectivesStuff.join()) // "," is default
            .forEach(e => e.remove());

    // Additionally remove the entire collective box from user profiles
    document.querySelector("a[href*=collectives].s-card")
           // Another optimization suggested by Oleg Valter
           // https://chat.stackoverflow.com/transcript/message/52657512#52657512
           ?.closest("div.flex--item")
           ?.remove();

})();
New contributor
Little Nuts is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
1
  • 2
    Welcome to Stack Apps! ;) and thanks for the helpful userscript. :) – Kevin M. Mansour Jul 19 at 20:04

You must log in to answer this question.

Browse other questions tagged .