Upwork external links

Skip "You are now leaving Upwork" page with external links

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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.

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

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

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.

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

// ==UserScript==
// @name         Upwork external links
// @description  Skip "You are now leaving Upwork" page with external links
// @namespace    vokracko
// @author       Lukáš Vokráčko
// @include      https://www.upwork.com/*
// @version      1.0
// @grant        none
// @encoding     utf-8
// ==/UserScript==

var target = document.querySelector('body');
var config = { attributes: false, childList: true, characterData: false, subtree: true };

function replace() {
    // replace links
    var links = document.links;

    for (var i in links) {
        if (links[i].href && links[i].href.startsWith("https://www.upwork.com/leaving")) {
            if (links[i].classList.contains("url-preview-title")) {
                links[i].href = decodeURIComponent(links[i].href.substr(35));
            } else {
                links[i].href = links[i].text;
            }
        }
    }
}

var observer = new MutationObserver(function (mutations) {
    mutations.forEach(function (mutation) {
        if (mutation.addedNodes) {
            replace();
        }
    });
});

observer.observe(target, config);