linkedin-clean-url

Cleans the tracking stuff from LinkedIn URLs.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);
  }
}());