does anyone know a script preferably Tampermonkey script which check people who see your story and if a specific person sees it to sent you a notification? Is that even possible? I have tried to do this but for me with my lack of knowledge on js I couldn’t manage to even get if the person saw it and then to even get a notification.
I am using:
Opera One (version: 111.0.5138.0) (arm64)
Opera is up to date Update
Update stream: developer
System: macOS Version 14.5 (Build 23F5059e) 14.5.0 arm64
Chromium version: 124.0.6356.6
And Mac mini, Sonoma 14.5 Beta (23F5059e)
Here is the script I tried:
// ==UserScript==
// @name Instagram Story Notifier
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Notify when a specific person views your Instagram story
// @author You
// @match https://www.instagram.com/*
// @grant none
// ==/UserScript==
console.log('Instagram Story Notifier script loaded');
(function() {
'use strict';
const targetUsers = ['usr1', 'usr2', 'usr3']; // Add the usernames you want to monitor
const notificationMessage = 'Someone viewed your story';
const observer = new MutationObserver(() => {
const storyViewsContainer = document.querySelector('div[role="dialog"] ul li');
if (storyViewsContainer) {
console.log('Story views container found!');
checkStoryViews();
observer.disconnect(); // stop observing
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
function checkStoryViews() {
console.log('Checking story views...');
const viewers = Array.prototype.slice.call(storyViewsContainer.children);
const viewerUsernames = viewers.map(viewer => viewer.querySelector('span').textContent);
console.log('Viewers:', viewerUsernames);
targetUsers.forEach(targetUser => {
if (viewerUsernames.includes(targetUser)) {
console.log(`Target user ${targetUser} found`);
notify(targetUser);
} else {
console.log(`Target user ${targetUser} not found`);
}
});
}
function notify(username) {
alert(`${username} viewed your story`);
}
})();