Pipermail date view: reversed timestamped

In the date view of a Pipermail archive, reverse the sorting of entries (newest on top) and add the message timestamp

  1. // ==UserScript==
  2. // @name Pipermail date view: reversed timestamped
  3. // @namespace armeagle.nl
  4. // @description In the date view of a Pipermail archive, reverse the sorting of entries (newest on top) and add the message timestamp
  5. // @include */pipermail/*/*/date.html
  6. // @version 1
  7. // ==/UserScript==
  8.  
  9. var list = document.querySelectorAll('body > ul')[1];
  10. var entries = list.querySelectorAll('li');
  11. if (entries.length > 1) {
  12. var topEntry = entries[0];
  13. timestampify(topEntry);
  14. for (index = 1; index < entries.length; index++) {
  15. var entry = entries[index];
  16. topEntry.parentNode.insertBefore(entry, topEntry);
  17. topEntry = entry;
  18. timestampify(topEntry);
  19. }
  20. }
  21.  
  22. function timestampify(entry) {
  23. var link = entry.querySelector('a');
  24. var url = link.getAttribute('href');
  25. GM_xmlhttpRequest({
  26. method: "GET",
  27. url: link.getAttribute('href'),
  28. onload: function(response) {
  29. if (!response.responseXML) {
  30. response.responseXML = new DOMParser()
  31. .parseFromString(response.responseText, "text/html");
  32. }
  33. var timestamp = response.responseXML.querySelector('body > i').textContent;
  34. var timestampElement = document.createElement('small');
  35. timestampElement.appendChild(document.createTextNode(timestamp));
  36. entry.appendChild(timestampElement);
  37. }
  38. });
  39. console.log(url);
  40. }