Remove User ID from Stack Overflow Share URLs

Removes the User ID from the URL displayed by the "Share" button for questions and answers on Stack Overflow and related sites. For a description of why the User ID was added, see https://meta.stackoverflow.com/q/277769

Author
Kevin Locke
Daily installs
0
Total installs
8
Ratings
0 0 0
Version
1.0.0
Created
Updated
License
MIT
Applies to

Author's Description

StackOverflow Share Remove User ID Userscript

A userscript (viz.
Greasemonkey/Tampermonkey/Violentmonkey
script) to remove the User ID from short URLs displayed by the "Share" button
on Stack Overflow and other Stack Exchange
sites
.

Important: The User ID is used to attribute links to your user account for
badges
. Removing it will remove the
link attribution and prevent you from obtaining those badges.

Given the above restriction, why would someone want to remove the User ID?
For me, the value of shorter, anonymous, user-invariant URLs far outweighs the
value of link attribution. Others may have specific tools or use cases for
Stack Overflow URLs which expect a certain format.

Features

  • Removes the User ID from both question and answer URLs.
  • Re-selects the URL text after changing to preserve copy behavior.
  • Only removes the User ID from recognized URL formats. If URL formats
    change, there should be no risk of removing non-User ID URL parts.

Installation

This userscript can be installed by following the instructions to install in
Greasemonkey
,
install in Tampermonkey, or install
in any other userscript manager using:

https://raw.githubusercontent.com/kevinoid/stackoverflow-share-remove-user-id/master/stackoverflow-share-remove-user-id.user.js

Contributing

Contributions are welcome and very much appreciated! Please add tests where
possible and ensure npm test passes.

If the desired change is large, complex, backwards-incompatible, can have
significantly differing implementations, or may not be in scope for this
project, opening an issue before writing the code can avoid frustration and
save a lot of time and effort.

License

This project is available under the terms of the
MIT License.