Skip to content

Instantly share code, notes, and snippets.

@andersonbosa
Created November 6, 2020 19:08
Show Gist options
  • Save andersonbosa/7e41e11a002518e8e9beaf6be9f3c946 to your computer and use it in GitHub Desktop.
Save andersonbosa/7e41e11a002518e8e9beaf6be9f3c946 to your computer and use it in GitHub Desktop.
/**
* Save everything that Tinder used to make a request to your data in the window.
*/
function hackRequest(request) {
window.tinderCoreRequestRequeriments = {
headers: response.headers,
url: response.url,
referrer: "https://tinder.com/",
referrerPolicy: "origin",
body: null,
method: "GET",
mode: "cors",
credentials: "omit"
}
}
/**
* executed callback on request interception.
*
* @param {*} request
*/
function interceptFetchApi(request) {
hackRequest(request)
}
function handleTinderCoreResponse(response) {
console.log(response);
}
/**
* Override the Fetch API to intercept the response.
*
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API}
* @param {String} urlPatternToIntercept
*/
const rewriteFetchApiToInterceptUrlPattern = (urlPatternToIntercept) => {
const originalFetch = window.fetch
window.fetch = (url, options) => {
const isToIntercept = urlPatternToIntercept.test(url)
if (isToIntercept) {
interceptFetchApi({ ...options, url })
return originalFetch(url, options)
.then(resp => resp.json())
.then(resp => handleTinderCoreResponse(resp))
} else {
return originalFetch(url, options)
}
}
}
rewriteFetchApiToInterceptUrlPattern(/v2\/recs\/core/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment