Skip to content

Instantly share code, notes, and snippets.



Last active Jun 7, 2020
What would you like to do?
Guesstimate the original tweet of a shared video on Twitter
javascript:(()=>{const match=document.title.match(/(\bhttps?:\/\/t\.co\/[a-zA-Z0-9\-\.as]+)/g);if(match!==null){window.location=match.slice(-1)[0]}})()
* Guesstimate the original tweet of a video that’s been shared as other tweet.
* This should work on unless something breaks on Twitter’s oEmbed API
* @author @wongmjane
const tweetUrlOrId = prompt('ID/URL of the Tweet?')
if (tweetUrlOrId === null) throw new Error('User bailed.')
const matches = tweetUrlOrId.match(
if (matches === null) throw new Error('Invalid format for a tweet ID/URL.')
.then(res => res.json())
.then(text => {
new DOMParser()
.parseFromString(text.html, 'text/html')
.querySelectorAll('.twitter-tweet > p[lang] > a[href]'),
a => /^pic\.twitter\.com\//.test(a.innerText),
.filter(a => /^https:\/\/t\.co\//.test(a))
.map(a => a.href),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.