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 για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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