JSFiddle - React, Tailwind, and code Playground
by Emre Erkan
JavaScript
(() => {
const scrollToBeVisible = function (ele, container) {
const eleTop = ele.offsetTop;
const eleBottom = eleTop + ele.clientHeight;
const containerTop = container.scrollTop;
const containerBottom = containerTop + container.clientHeight;
if (eleTop < containerTop) {
container.scrollTop -= containerTop - eleTop;
} else if (eleBottom > containerBottom) {
container.scrollTop += eleBottom - containerBottom;
}
};
const sendMessage = () => {
document.querySelector('.comms-icons.email').click();
document.querySelector('textarea.message.custom-email-body').value="Test mesajı";
/**
* Aşağıdakini açınca mesajı gönderir.
*/
// document.querySelector('.contact-details .activateButton').click();
/**
* Mesaj listesine geri dönmek için aşağıdaki kullanılabilir ama mesaj
* gönderildiğinde ne olduğunu bilmediğim için bu kısmı yapmadım.
*/
// document.querySelector('a.contact-head-icon.back').click();
};
const handleContacts = () => {
const wrapper = document.querySelector('.contact-wrapper');
const message = document.querySelector('a.contact-card');
/**
* Infinite scroll olayını handle etmek için mesajın olduğu yere kaydırıyoruz.
* Sonra mesaj bağlantısında .click() tetikliyoruz.
*/
scrollToBeVisible(message, wrapper);
/**
* Burada delay ya da bir observer daha gerekiyor muhtemelen
* Contact list'e geri dönünce çok hızlı click oluyor. Sistem şaşalıyor.
*/
//message.click();
};
const side = document.getElementById('side');
MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
const obs = new MutationObserver((mutations, observer) => {
for(let idx = 0, idl = mutations.length; idx < idl; idx++) {
if (mutations[idx].addedNodes.length === 0 || mutations[idx].addedNodes[0].classList.contains('overlay')) {
continue;
}
console.log(mutations[idx].addedNodes[0]);
...