Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mirhossein committed Jun 11, 2024
1 parent aa311fc commit 67207ac
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function createSurflySession(contactId, inviteType) {

function sendFollowerLink(followerLink, type, uniquePageId, channelId) {
fetch(
"https://nic.surf.ly/follower_link",
"https://admin-api-backend-ef6aeff35287.herokuapp.com/follower_link",
{
method: "POST",
headers: {
Expand Down Expand Up @@ -376,3 +376,35 @@ function initializeChatNiC() {

console.log('Initializing NiC');
}

var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
mutation.addedNodes.forEach(function (node) {
console.log("node added 1", node);
// Check a second condition to make sure it's the chat widget
var chat_messenger_frame = document.getElementById("icChat");
if (!chat_messenger_frame) {
return;
}
console.log("Chat messenger frame found", chat_messenger_frame);
observer.disconnect();
var new_observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
mutation.addedNodes.forEach(function (node) {
console.log("node added 2", node);
});
mutation.removedNodes.forEach(function (node) {
console.log("node removed 2", node);
});
mutation.attributeName.forEach(function (node) {
console.log("node attribute 2", node);
});
});
});
new_observer.observe(chat_messenger_frame.contentWindow.document.body, { childList: true, subtree: true, attributes: true, characterData: true});
console.log("Observer added 2", new_observer);
});
});
});
var chat_messenger_frame = document.getElementById("icChat");
observer.observe(document, { childList: true, subtree: true});

0 comments on commit 67207ac

Please sign in to comment.