bypass LoggedIn Requirement in Twitter

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

  1. // ==UserScript==
  2. // @name bypass LoggedIn Requirement in Twitter
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Script to redirect user to twitter embed link, to avoud requirement of beeing logging in
  6. // @author You
  7. // @match https://twitter.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com
  9. // @grant none
  10. // @esversion 8
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. function sleep(ms) {
  17. return new Promise(resolve => setTimeout(resolve, ms));
  18. }
  19.  
  20. async function main() {
  21. console.log('Before 3 seconds of sleep');
  22. await sleep(3000);
  23. let xpathResultMark1 = document.evaluate("//*[text()='Sign up']", document, null, XPathResult.ANY_TYPE, null);
  24. let xpathResultMark2 = document.evaluate("//*[text()='Retry']", document, null, XPathResult.ANY_TYPE, null);
  25.  
  26. let node1 = xpathResultMark1.iterateNext();
  27. let node2 = xpathResultMark2.iterateNext();
  28.  
  29. if (node1 && node2) {
  30. console.log("Text 'Sign up' and 'Retry' is present in the HTML document.");
  31.  
  32. let link = "https://platform.twitter.com/embed/Tweet.html?id=%s"
  33.  
  34. let currentURL = window.location.href;
  35.  
  36. let url = currentURL;
  37. let regex = /[^/]*$/;
  38. let lastPart = url.match(regex)[0];
  39.  
  40. let targetPage = `https://platform.twitter.com/embed/Tweet.html?id=${lastPart}`
  41. window.location.href = targetPage;
  42. } else {
  43. console.log("Text 'Sign up' and 'Retry' is NOT present in the HTML document. you are logged in");
  44. console.log(node1);
  45. console.log(node2);
  46. }
  47. }
  48.  
  49. main();
  50. })();