-
-
Save twilight-sparkle-irl/6040275212f8822e48ef535459c97d44 to your computer and use it in GitHub Desktop.
$(document).ajaxComplete((e, x, o) => { | |
if (o.url == "https://api.twitter.com/1.1/statuses/retweet.json") { | |
tweet_id = JSON.parse(x.responseText)['id_str']; | |
auth_token = JSON.parse(document.querySelector('#init-data').value)['formAuthenticityToken']; | |
fetch("https://twitter.com/i/tweet/pin", { | |
body: `authenticity_token=${auth_token}&id=${tweet_id}`, | |
method: "POST", | |
headers: { | |
Accept: "application/json, text/javascript, */*; q=0.01", | |
"Cache-Control": "no-cache", | |
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", | |
"X-Requested-With": "XMLHttpRequest", | |
"X-Twitter-Active-User": "yes" | |
} | |
}).then(res => res.json()).then(res => $(document).trigger('uiShowError', res)) | |
} | |
}) | |
// paste this into javascript console on a twitter permalink status page (https://twitter.com/[user]/status/[id]) | |
// this will make any tweet you retweet on that page also pin itself to your profile | |
// this is very laggy bc jquery sucks | |
// so i recommend opening your tweet in a new tab, pasting the code, retweeting, and then closing the tab | |
// also this only works on old twitter, not nu PWA twitter | |
// enjoi | |
// oh also | |
// this works because when you retweet a tweet, you get a tweet id | |
// this is not the original tweet's id, this is actually the id *of your retweet* | |
// for backwards compatibility reasons, twitter, despite displaying them differently, actually has retweets stored as normal tweets | |
// and these normal tweets are attributed to you | |
// so since it's a tweet, and it's attributed to you, the /i/tweet/pin api goes "well ok" and pins it bc it never checks if its a retweet |
getting "SyntaxError: '[object HTMLDocument]' is not a valid selector"
is this why it's currently not working?
you need to be on the old layout
hi, i am having trouble with doing this. could you possibly help me? my twitter is @z4nii if you want to contact me that way. thanks!
I'm getting "Failed to load resource: net: : EER_BLOCKED_BY_CLIENT" after I retweet the tweet I want to pin. Is there a fix?
(It worked when I tried it again, my apologies)
Old layout is discontinued, consider porting this to the new layout
@sks316 Requires ability to sign requests using oauth, cannot currently figure out obvious way to do this.
Until then, get Twitter oauth keys with R/W access, grab retweet ID (can be done using network inspector), and then run this using twurl:
twurl -d "tweet_mode=extended&id=[retweet ID]" /1.1/account/pin_tweet.json
I think Twitter killed the loophole for account/pin_tweet
when they released v2, trying to get it to pin a retweet status now gets a 404 with 'errors':[{'code': 144, 'message': 'No status found with that ID.'}]
as the body even using v1.1.
getting "SyntaxError: '[object HTMLDocument]' is not a valid selector"
is this why it's currently not working?