Advertisement
Guest User

Userscript to return Twitter "orig" URL

a guest
Oct 2nd, 2023
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.63 KB | Source Code | 0 0
  1. // ==UserScript==
  2. // @name         View Full Twitter Image
  3. // @version      2.0.1
  4. // @description  Returns the full-size Twitter "orig" URL.
  5. // @match        https://pbs.twimg.com/media/*
  6. // ==/UserScript==
  7.  
  8. "use strict";
  9.  
  10. function urlConvert(url) {
  11.   const input = url.href;
  12.   const regex = /media\/(.*)(?:\?|\.).*(jpg|png)/m;
  13.   const match = input.match(regex);
  14.   if(match === null) return;
  15.   location.assign(`https://pbs.twimg.com/media/${match[1]}?format=${match[2]}&name=orig`);
  16. }
  17.  
  18. const url = new URL(location);
  19. if(url.searchParams.get("format") && url.searchParams.get("name") === "orig") return;
  20.  
  21. urlConvert(url);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement