Created
October 11, 2023 11:39
-
-
Save mihaeu/3dfa97dad113d6772d4a262ed0d6edea to your computer and use it in GitHub Desktop.
[Tampermonkey] OkCupid - Show all match images
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
// ==UserScript== | |
// @name OkCupid - Show all match images | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Shows all profile images for all your matches, but if you want to find the profiles you still need premium. Look at this like extra motivation. | |
// @author anonymous | |
// @match https://www.okcupid.com/who-likes-you | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=okcupid.com | |
// @grant none | |
// ==/UserScript== | |
let matchImages = [] | |
let moreMatchImages = true | |
let afterMatchImages = '' | |
const {fetch: origFetch} = window; | |
window.fetch = async (...args) => { | |
const response = await origFetch(...args); | |
if (args[0] !== 'https://www.okcupid.com/graphql?operationName=userrowsIncomingLikes') { | |
return response | |
} | |
console.log("Intercepted fetch call with args:", args); | |
const json = await response | |
.clone() | |
.json(); | |
json.data.me.likes.data.forEach(matchPreview => matchImages.push(matchPreview.primaryImage.square225)) | |
moreMatchImages = json.data.me.likes.pageInfo.hasMore | |
afterMatchImages = json.data.me.likes.pageInfo.after | |
console.log(moreMatchImages, afterMatchImages) | |
while (moreMatchImages) { | |
args[1].body = args[1].body.replace(/(DESC_TIMESTAMP")/, `$1,"after":"${afterMatchImages}"`) | |
const response = await origFetch(...args); | |
const json = await response.json() | |
json.data.me.likes.data.forEach(matchPreview => matchImages.push(matchPreview.primaryImage.square225)) | |
moreMatchImages = json.data.me.likes.pageInfo.hasMore | |
afterMatchImages = json.data.me.likes.pageInfo.after | |
} | |
return new Response(JSON.stringify(json)); | |
}; | |
const matchCheckIntervalId = setInterval(() => { | |
if (matchImages.length > 0) { | |
document.querySelector('[data-cy="likesPage.whoLikesYouContent"]').innerHTML = `<section>${matchImages.map((img, i) => `<img src="${img}" alt="match-preview-${i}" />`)}</section>` | |
clearInterval(matchCheckIntervalId) | |
} | |
}, 1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment