Created
November 6, 2020 19:08
-
-
Save andersonbosa/7e41e11a002518e8e9beaf6be9f3c946 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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