linkedin-clean-url

Cleans the tracking stuff from LinkedIn URLs.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(У мене вже є менеджер скриптів, дайте мені встановити його!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        linkedin-clean-url
// @description Cleans the tracking stuff from LinkedIn URLs.
// @homepageURL https://github.com/caglartoklu/linkedin-clean-url.user.js
// @author      Caglar Toklu
// @version     1.0.0
// @date        2016-04-11
// @namespace   https://github.com/caglartoklu/greasemonkey
// @license     BSD 2-Clause
// @copyright   2016, Caglar Toklu
// @include     http://*linkedin.com/*
// @include     https://*linkedin.com/*
// @run-at      document-start
// @grant       none
// ==/UserScript==

// if you use this script,
// https://www.linkedin.com/pulse/some-topic-some-guy?trk=eml-b...
// becomes:
// https://www.linkedin.com/pulse/some-topic-some-guy

// also, the following:
// https://www.linkedin.com/home?trk=nav_responsive_tab_home
// becomes:
// https://www.linkedin.com/home

// This script does not increase the security, nor it provides privacy.
// LinkedIn will still be able to track you.

(function () {

  var debugPrint = function (message) {
    var indicator = "linkedin-clean-url.user.js : ";
    var debugMode = false;
    if (debugMode) {
      console.log(indicator + message);
    }
  };

  var deleteAfter = function (haystack, needle) {
    // Returns a copy of haystack where all the characters after needle is removed.
    // If needle does not occur in haystack, then haystack will be returned as it is.
    // haystack: string, the big string.
    // needle: string, the small string to be found.
    var result = haystack;
    var position = haystack.indexOf(needle);
    if (position > - 1) {
      result = haystack.substr(0, position);
    }
    return result;
  };

  var cleanLinkedInUrl = function (url) {
    var needle = '?trk=';
    return deleteAfter(url, needle);
  };

  var currentUrl = window.location.href;
  var newUrl = cleanLinkedInUrl(window.location.href);
  if (currentUrl != newUrl) {
    // change the URL if and only if has tracking.
    window.location.replace(newUrl);
  }
}());