Direct Links to Twitter Media Embeds

Generates a small link directly to the source of Twitter media embeds (Youtube, Twitch clips, etc.)

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         Direct Links to Twitter Media Embeds
// @namespace    http://bifrost.me
// @version      1.0
// @description  Generates a small link directly to the source of Twitter media embeds (Youtube, Twitch clips, etc.)
// @match        https://twitter.com/*
// @grant        none
// @require		 https://code.jquery.com/jquery-1.12.4.min.js
// ==/UserScript==

var documentHeight = '';

// Monitor the height of the window to detect when new tweets have been dynamically loaded
function heightWatcher() {
    if (documentHeight != document.body.scrollHeight) {
        addLinks();
    }
    documentHeight = document.body.scrollHeight;
    setTimeout(function(){heightWatcher();}, 3000);
};

function addLinks() {
    $('div.card-type-player').each(function() {
        if ($(this).attr('link-added')) {
            return;
        }
        const src = $(this).attr('data-card-url');
        $(this).before('<a href=\"' + src + '\">→</a>');
        $(this).attr('link-added', true)
    });
};

(function() {
    'use strict';

    heightWatcher();
})();