Skip to content

Commit

Permalink
Merge branch 'account-created-display'
Browse files Browse the repository at this point in the history
  • Loading branch information
Acorn221 committed Oct 27, 2023
2 parents a56b722 + 3daf6c7 commit 7c77a87
Show file tree
Hide file tree
Showing 23 changed files with 690 additions and 188 deletions.
Binary file added assets/LighterFuel.psd
Binary file not shown.
Binary file added assets/LighterfuelPromo1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/LighterfuelPromo1.psd
Binary file not shown.
Binary file added assets/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/banner.psd
Binary file not shown.
Binary file added assets/promoBanner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/promoBanner.psd
Binary file not shown.
Binary file added assets/smallPromo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/smallPromo.psd
Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "lighter-fuel-for-tinder",
"displayName": "LighterFuel for tinder",
"version": "1.4.7",
"description": "LighterFuel helps you to identify catfish, letting you see when profile images were uploaded and reverse image search photos!",
"version": "1.4.8",
"description": "LighterFuel helps you see when accounts were created, see enlarged photos and reverse image search photos!",
"author": "James",
"scripts": {
"dev": "plasmo dev",
Expand Down
84 changes: 84 additions & 0 deletions src/background/PeopleHandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* eslint-disable class-methods-use-this */
/* eslint-disable no-restricted-syntax */
/* eslint-disable no-underscore-dangle */
import type { Person } from '~src/misc/tinderTypes';

export type photoInfo = {
hqUrl: string;
accountCreated: number;
original: string;
} | undefined;

const dateFromObjectId = (objectId) => new Date(parseInt(objectId.substring(0, 8), 16) * 1000);

const extractRecPhotoId = (url: string) => {
const regex = /\/u\/([^/]+)/;
const match = url.match(regex);
return match ? match[1] : null;
};

// this gets the uuid of the photo from the url
const extractUuidFromUrl = (url) => {
const regex = /_(.*?)\./;
const match = url.match(regex);
if (match && match[1]) {
const uuid = match[1].replace(/^(\d+)_/, '');
return uuid;
}
return null;
};

export class PeopleHandler {
people: Person[] = [];

handleNewPeople(people: Person[]) {
people.forEach((person) => {
if (!this.people.find((p) => p._id === person._id)) {
this.people.push(person);
}
});

console.log('people', this.people);
}

/**
* This
* @param url the photo URL attached to the account
*/
getInfoFromPhoto(url: string): photoInfo {
// search through all of the people
for (const person of this.people) {
if (person.type === 'match') {
const photoId = extractUuidFromUrl(url);
// search through person's photos
for (const photo of person.photos) {
if (photo.id === photoId) {
// return photoRecord details immediately when you get a match
return {
original: url,
hqUrl: photo.url,
accountCreated: dateFromObjectId(person._id).getTime(),
};
}
}
} else if (person.type === 'rec') {
const id = extractRecPhotoId(url);
// search through person's photos
for (const photo of person.photos) {
if (extractRecPhotoId(photo.url) === id) {
if (!photo.url) console.error('no photo url, recs', photo);

// return photoRecord details immediately when you get a match
return {
original: url,
hqUrl: photo.url,
accountCreated: dateFromObjectId(person._id).getTime(),
};
}
}
}
}
console.error('no match found for url', url);
return undefined;
}
}
11 changes: 7 additions & 4 deletions src/background/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Sites } from '@/misc/types';
import ImageRequestCapturer from './imageRequestCapturer';
import { SENTRY_DSN } from './Misc';
import { AnalyticsEvent } from '~src/misc/GA';
import { PeopleHandler } from './PeopleHandler';

const setAndCheckDefaultSettings = async () => {
const storage = new Storage();
Expand Down Expand Up @@ -40,25 +41,27 @@ const setupSentry = async () => {
}
};

let tinderRequestCap: ImageRequestCapturer;
let mambaRequestCap: ImageRequestCapturer;
let peopleHandler: PeopleHandler;

try {
setupSentry();
setAndCheckDefaultSettings();

tinderRequestCap = new ImageRequestCapturer(['*://*.gotinder.com/*/*.jpg*', '*://*.gotinder.com/*/*.webp*', '*://*.gotinder.com/*/*.mp4*'], Sites.TINDER);
peopleHandler = new PeopleHandler();

mambaRequestCap = new ImageRequestCapturer(['*://*.wmbcdn.com/*'], Sites.MAMBA, 1000);

// prints the bg instance to the console for debugging!
if (debug) console.log(tinderRequestCap, mambaRequestCap);
if (debug) console.log(mambaRequestCap);
if (debug) console.log('people handler', peopleHandler);
} catch (err: any) {
console.error(`Error caught in background.js: ${err.stack}`);
}

// exporting so the message handlers can access the images
export {
tinderRequestCap,
peopleHandler,
mambaRequestCap,
};

Expand Down
20 changes: 20 additions & 0 deletions src/background/messages/getImageInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { PlasmoMessaging } from '@plasmohq/messaging';
import { peopleHandler } from '..';
import type { photoInfo } from '../PeopleHandler';

export type getImageInfoRequest = {
url: string;
};

export type getImageInfoResponse = {
info: photoInfo;
};

const handler: PlasmoMessaging.MessageHandler<getImageInfoRequest, getImageInfoResponse> = async (req, res) => {
const info = peopleHandler.getInfoFromPhoto(req.body.url);
res.send({
info,
});
};

export default handler;
5 changes: 1 addition & 4 deletions src/background/messages/getImages.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { PlasmoMessaging } from '@plasmohq/messaging';
import { tinderRequestCap, mambaRequestCap } from '@/background/index';
import { mambaRequestCap } from '@/background/index';
import { type ImageType, Sites } from '@/misc/types';

export type getImagesRequest = {
Expand All @@ -21,9 +21,6 @@ const handler: PlasmoMessaging.MessageHandler<getImagesRequest, getImagesRespons
let images = [];

switch (req.body.site) {
case Sites.TINDER:
images = complete ? tinderRequestCap.getAllImages() : await tinderRequestCap.getNewImages();
break;
case Sites.MAMBA:
images = complete ? mambaRequestCap.getAllImages() : await mambaRequestCap.getNewImages();
break;
Expand Down
11 changes: 11 additions & 0 deletions src/background/messages/getPeople.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { PlasmoMessaging } from '@plasmohq/messaging';
import { peopleHandler } from '..';

const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
peopleHandler.handleNewPeople(req.body.people);
res.send({
recieved: true,
});
};

export default handler;
31 changes: 31 additions & 0 deletions src/contents/relay.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { relay } from '@plasmohq/messaging/relay';
import { sendToBackground } from '@plasmohq/messaging';
import type { getImagesRequest, getImagesResponse } from '~src/background/messages/getImages';
import type { getImageInfoRequest, getImageInfoResponse } from '~src/background/messages/getImageInfo';

relay<string, getImagesRequest, getImagesResponse>(
{
Expand All @@ -21,3 +22,33 @@ relay<string, getImagesRequest, getImagesResponse>(
return res;
},
);

relay<string, any, any>(
{
name: 'getPeople',
},
async (req) => {
let res: getImagesResponse = {
images: [],
};
try {
res = await sendToBackground({
name: 'getPeople',
body: req.body,
});
} catch (e) {
console.log(`Error thrown in getPeople relay, ${e}`);
}
return res;
},
);

relay<string, getImageInfoRequest, getImageInfoResponse>(
{
name: 'getImageInfo',
},
async (req) => sendToBackground<getImageInfoRequest, getImageInfoResponse>({
name: 'getImageInfo',
body: req.body,
}),
);
16 changes: 16 additions & 0 deletions src/contents/tinderProfileGetter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { PlasmoCSConfig } from 'plasmo';
import ProfileGetter from '~src/contentsHelpers/ProfileGetter';

export const config: PlasmoCSConfig = {
matches: ['*://tinder.com/*'],
run_at: 'document_start',
world: 'MAIN',
};

try {
const getter = new ProfileGetter();

console.log('Getter created!');
} catch (e) {
console.error(`Error in profile getter: ${e}`);
}
2 changes: 1 addition & 1 deletion src/contentsHelpers/ImageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* eslint-disable no-restricted-syntax */
import browser from 'webextension-polyfill';
import { Storage } from '@plasmohq/storage';
import { sendToBackground } from '@plasmohq/messaging';
import { sendToBackground, sendToBackgroundViaRelay } from '@plasmohq/messaging';

import EventEmitter from 'events';
import {
Expand Down
Loading

0 comments on commit 7c77a87

Please sign in to comment.