Skip to content

Commit d65b06c

Browse files
committed
Fix MeetMe iframe viewer handling
1 parent d653f28 commit d65b06c

1 file changed

Lines changed: 12 additions & 28 deletions

File tree

sources/meetme.js

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ function toDataURL(url, callback) {
133133
if (!img){return "";}
134134
var src = "";
135135
try {
136-
src = img.getAttribute("src") || img.src || "";
136+
if (!img.hasAttribute || !img.hasAttribute("src")){
137+
return "";
138+
}
139+
src = img.getAttribute("src") || "";
137140
} catch(e){}
138141
if (!src || src.indexOf("no_photo.svg") !== -1){
139142
return "";
@@ -142,7 +145,8 @@ function toDataURL(url, callback) {
142145
return src;
143146
}
144147
try {
145-
return new URL(src, window.location.href).href;
148+
var resolved = new URL(src, window.location.href).href;
149+
return resolved === window.location.href ? "" : resolved;
146150
} catch(e){
147151
return src;
148152
}
@@ -364,6 +368,8 @@ function toDataURL(url, callback) {
364368

365369
function getDomViewerCount() {
366370
var selectors = [
371+
".swiper-slide-active [class*='viewers-count'] span",
372+
".swiper-slide-active [class*='viewers-count']",
367373
"[class*='viewers-count'] span",
368374
".viewers-count___KREgV span",
369375
"[class*='viewers-count']"
@@ -848,22 +854,6 @@ function toDataURL(url, callback) {
848854
});
849855
}
850856

851-
function isEmbeddedFrame() {
852-
try {
853-
return window.top && window.top !== window;
854-
} catch(e) {
855-
return true;
856-
}
857-
}
858-
859-
function isMeetMeTopPage() {
860-
try {
861-
return window.location && window.location.hostname === "app.meetme.com";
862-
} catch(e) {
863-
return false;
864-
}
865-
}
866-
867857
function handleMeetMeWsSent(rawData) {
868858
var frame = parseWsJson(rawData);
869859
if (!frame || frame.op !== "subscribe" || !frame.query || frame.requestId === undefined || frame.requestId === null) {
@@ -910,16 +900,7 @@ function toDataURL(url, callback) {
910900
}
911901

912902
function handleMeetMeWindowMessage(event) {
913-
if (!event || !event.data || event.data.source !== "meetme-ws-interceptor") {
914-
return;
915-
}
916-
if (event.source === window && isEmbeddedFrame()) {
917-
try {
918-
window.top.postMessage(event.data, "*");
919-
} catch(e){}
920-
return;
921-
}
922-
if (event.source !== window && !isMeetMeTopPage()) {
903+
if (!event || event.source !== window || !event.data || event.data.source !== "meetme-ws-interceptor") {
923904
return;
924905
}
925906
if (event.data.type === "send") {
@@ -946,6 +927,9 @@ function toDataURL(url, callback) {
946927
if (avatar){
947928
chatimg = getImageSrc(avatar);
948929
avatarAlt = avatar.alt || "";
930+
if (/^(user avatar|stream avatar|avatar)$/i.test(avatarAlt.trim())){
931+
avatarAlt = "";
932+
}
949933
}
950934
} catch(e){
951935
}

0 commit comments

Comments
 (0)