Advertisement
DPOH-VAR

CynicmansionTime

Oct 6th, 2016
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var authorPostsTime = Array
  2.     .from(document.querySelectorAll(".b-comment__user"))
  3.     .filter(_=>_.querySelector(".b-comment__user_author_story"))
  4.     .map(_=>_.querySelector(".b-comment__time"))
  5.     .map(_=>_.getAttribute("datetime"))
  6.     .map(_=>new Date(+_*1000));
  7. var commentTime = new Date(Math.min(...authorPostsTime));
  8.  
  9. void new Promise(resolve => {
  10.     var xhr = new XMLHttpRequest();
  11.     xhr.responseType = 'document';
  12.     xhr.open("GET", location.href);
  13.     xhr.onreadystatechange = () => xhr.readyState == 4 && resolve(xhr);
  14.     xhr.send();
  15. })
  16.     .then(_=>_.responseXML)
  17.     .then(_=>_.querySelector("div.story__date[title]"))
  18.     .then(_=>_.getAttribute("title"))
  19.     .then(_=>new Date(+_*1000))
  20.     .then(postTime => console.table({
  21.         "Пост":  {"value":postTime.toLocaleString()},
  22.         "Комментарий": {"value":commentTime.toLocaleString()},
  23.         "Ранзица, секунд": {"value":(commentTime-postTime)/1000}
  24.     }));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement