Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var authorPostsTime = Array
- .from(document.querySelectorAll(".b-comment__user"))
- .filter(_=>_.querySelector(".b-comment__user_author_story"))
- .map(_=>_.querySelector(".b-comment__time"))
- .map(_=>_.getAttribute("datetime"))
- .map(_=>new Date(+_*1000));
- var commentTime = new Date(Math.min(...authorPostsTime));
- void new Promise(resolve => {
- var xhr = new XMLHttpRequest();
- xhr.responseType = 'document';
- xhr.open("GET", location.href);
- xhr.onreadystatechange = () => xhr.readyState == 4 && resolve(xhr);
- xhr.send();
- })
- .then(_=>_.responseXML)
- .then(_=>_.querySelector("div.story__date[title]"))
- .then(_=>_.getAttribute("title"))
- .then(_=>new Date(+_*1000))
- .then(postTime => console.table({
- "Пост": {"value":postTime.toLocaleString()},
- "Комментарий": {"value":commentTime.toLocaleString()},
- "Ранзица, секунд": {"value":(commentTime-postTime)/1000}
- }));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement