LinkedIn Recent Activity Redirect

Redirects LinkedIn profile pages to recent activity

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

// ==UserScript==
// @name         LinkedIn Recent Activity Redirect
// @namespace    https://github.com/chr1sx
// @version      1.0.1
// @description  Redirects LinkedIn profile pages to recent activity
// @author       chr1sx
// @match        https://www.linkedin.com/*
// @grant        window.onurlchange
// @run-at       document-start
// @license      MIT
// @icon         https://www.google.com/s2/favicons?domain=linkedin.com&sz=64
// ==/UserScript==

(function() {
    'use strict';

    function checkAndRedirect() {
        const currentUrl = window.location.href;

        const profileRegex = /^https:\/\/www\.linkedin\.com\/in\/[^/]+\/?(\?.*)?$/;

        if (profileRegex.test(currentUrl)) {
            if (!currentUrl.includes('/recent-activity')) {
                const baseUrl = currentUrl.split('?')[0].replace(/\/$/, "");
                const activityUrl = `${baseUrl}/recent-activity/all/`;

                console.log('[Redirector] Redirecting to:', activityUrl);
                window.location.replace(activityUrl);
            }
        }
    }

    checkAndRedirect();

    let lastUrl = location.href;
    const observer = new MutationObserver(() => {
        const url = location.href;
        if (url !== lastUrl) {
            lastUrl = url;
            checkAndRedirect();
        }
    });

    observer.observe(document, { subtree: true, childList: true });

    window.addEventListener('popstate', checkAndRedirect);

    const pushState = history.pushState;
    history.pushState = function() {
        pushState.apply(history, arguments);
        checkAndRedirect();
    };
})();