Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dclstn committed May 13, 2024
1 parent 49c15a2 commit 70df680
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

This browser extension enhances your web.snapchat.com experience by adding several essential privacy features.

- [x] **Appear on Mobile** - Disguise your client as if you're sending from from a phone!
- [x] **Allow Screenshots** - Allow screenshots to be captured everywhere!
- [x] **Always Present** - Prevent away-state from showing when clicking away!
- [x] **Auto-Save Chats** - Automatically save chats when they're sent/recieved!
Expand All @@ -16,6 +17,8 @@ This browser extension enhances your web.snapchat.com experience by adding sever
- [x] **Cross-Browser Support** - Enable web.snapchat.com to work on any browser!
- [x] **Multiple-Tab Support** - Block snapchat's detection that you've opened multiple tabs!
- [x] **Stop Story View-Receipts** - Silently views others' snaps
- [x] **Half-Swipe Notification** - Recieve a notification when a chat is half-swiped!
- [x] **Open-Chat Notification** - Recieve a notification when a chat is opened!
- [ ] More to come...

## How to install
Expand Down
47 changes: 17 additions & 30 deletions src/script/modules/presence-notifications/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,7 @@ enum PresenceStates {
HALF_SWIPING = 256,
}

const halfSwipeNotifications = new Set();
function sendThrottledHalfSwipeNotification(presencePayload: any) {
if (halfSwipeNotifications.has(presencePayload.senderUserId)) {
return;
}
halfSwipeNotifications.add(presencePayload.senderUserId);
const notification = new Notification(presencePayload.senderUsername, { body: 'Peeking your Chat' });
setTimeout(() => {
halfSwipeNotifications.delete(presencePayload.senderUserId);
notification.close();
}, 10000);
}

const openChatNotifications = new Set();
function sendThrottledOpenChatNotification(presencePayload: any) {
if (openChatNotifications.has(presencePayload.senderUserId)) {
return;
}
openChatNotifications.add(presencePayload.senderUserId);
const notification = new Notification(presencePayload.senderUsername, { body: 'Opened your Chat' });
setTimeout(() => {
openChatNotifications.delete(presencePayload.senderUserId);
notification.close();
}, 10000);
}
const senderPresenceStates = new Map<string, number>();

(() => {
const GRPCTransientMessage = getTransientMessage();
Expand Down Expand Up @@ -65,19 +41,30 @@ function sendThrottledOpenChatNotification(presencePayload: any) {
const presencePayload = PresencePayload.decode(transientMessage.payload.data);
const presenceStateKey = `${presencePayload.senderUserId}:${presencePayload.senderSessionId}`;
const presenceState = presencePayload.presenceStates[presenceStateKey];

if (presenceState == null) {
senderPresenceStates.delete(presencePayload.senderUserId);
return listener(event);
}

// TODO: this might break, as I'm assuming 1:1 presenceState and extendedBits
if (presenceState.extendedBits === PresenceStates.HALF_SWIPING) {
sendThrottledHalfSwipeNotification(presencePayload);
const senderPrecenseState = senderPresenceStates.get(presencePayload.senderUserId);
if (senderPrecenseState === presenceState.extendedBits) {
return listener(event);
}

// TODO: this might break, as I'm assuming 1:1 presenceState and extendedBits
let notification: Notification | null = null;

if (presenceState.extendedBits === PresenceStates.IDLE) {
sendThrottledOpenChatNotification(presencePayload);
senderPresenceStates.set(presencePayload.senderUserId, presenceState.extendedBits);
notification = new Notification(presencePayload.senderUsername, { body: 'Opened your Chat' });
}

if (presenceState.extendedBits === PresenceStates.HALF_SWIPING) {
senderPresenceStates.set(presencePayload.senderUserId, presenceState.extendedBits);
notification = new Notification(presencePayload.senderUsername, { body: 'Peeked at your Chat' });
}

setTimeout(() => notification?.close(), 5000);
}
} catch (_) {}

Expand Down

0 comments on commit 70df680

Please sign in to comment.