Skip to content

Instantly share code, notes, and snippets.

@insin
Last active December 19, 2025 20:51
Show Gist options
  • Select an option

  • Save insin/baf3ff2965aaeb95509aeefda88c5a17 to your computer and use it in GitHub Desktop.

Select an option

Save insin/baf3ff2965aaeb95509aeefda88c5a17 to your computer and use it in GitHub Desktop.
Preview "Popular" sort for the Following timeline in Twitter Web
  1. Go to a page other than Home (e.g. Notifications)
  2. Refresh the tab so you don't have any Home timeline Tweets cached
  3. Paste the code from patch.js into the F12 developer Console
  4. Your Following feed will now be sorted by "Popular" until you next refresh the tab
void function () {
const XMLHttpRequest_open = XMLHttpRequest.prototype.open
XMLHttpRequest.prototype.open = function(method, url) {
if (url.includes('/HomeLatestTimeline')) {
if (method.toUpperCase() == 'GET') {
let request = new URL(url)
let params = new URLSearchParams(request.search)
let variables = JSON.parse(decodeURIComponent(params.get('variables')))
variables.enableRanking = true
params.set('variables', JSON.stringify(variables))
url = `${request.origin}${request.pathname}?${params.toString()}`
} else {
this._method = method.toUpperCase()
this._url = url
}
}
return XMLHttpRequest_open.apply(this, [method, url])
}
const XMLHttpRequest_send = XMLHttpRequest.prototype.send
XMLHttpRequest.prototype.send = function(body) {
if (body && this._method == 'POST' && this._url?.includes('/HomeLatestTimeline')) {
try {
let data = JSON.parse(body)
if (data.variables != null && typeof data.variables == 'object') {
data.variables.enableRanking = true
body = JSON.stringify(data)
}
} catch (e) {
// pass
}
}
return XMLHttpRequest_send.apply(this, [body])
}
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment