bypass LoggedIn Requirement in Twitter

Script to redirect user to twitter embed link, to avoud requirement of beeing logging in

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

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         bypass LoggedIn Requirement in Twitter
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Script to redirect user to twitter embed link, to avoud requirement of beeing logging in
// @author       You
// @match        https://twitter.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant        none
// @esversion    8
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    function sleep(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }

    async function main() {
        console.log('Before 3 seconds of sleep');
        await sleep(3000);
        let xpathResultMark1 = document.evaluate("//*[text()='Sign up']", document, null, XPathResult.ANY_TYPE, null);
        let xpathResultMark2 = document.evaluate("//*[text()='Retry']", document, null, XPathResult.ANY_TYPE, null);

        let node1 = xpathResultMark1.iterateNext();
        let node2 = xpathResultMark2.iterateNext();

        if (node1 && node2) {
            console.log("Text 'Sign up' and 'Retry' is present in the HTML document.");

            let link = "https://platform.twitter.com/embed/Tweet.html?id=%s"

            let currentURL = window.location.href;

            let url = currentURL;
            let regex = /[^/]*$/;
            let lastPart = url.match(regex)[0];

            let targetPage = `https://platform.twitter.com/embed/Tweet.html?id=${lastPart}`
            window.location.href = targetPage;
        } else {
            console.log("Text 'Sign up' and 'Retry' is NOT present in the HTML document. you are logged in");
            console.log(node1);
            console.log(node2);
        }
    }

    main();
})();