IGGGAMES - Show Modified Time for Posts

So you can tell if something is really updated. Also for PCGamesTorrents.

当前为 2022-02-14 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IGGGAMES - Show Modified Time for Posts
  3. // @description So you can tell if something is really updated. Also for PCGamesTorrents.
  4. // @namespace RainSlide
  5. // @author RainSlide
  6. // @icon https://igg-games.com/favicon.ico
  7. // @version 1.1
  8. // @match https://igg-games.com/*
  9. // @match https://pcgamestorrents.com/*
  10. // @grant none
  11. // @license AGPL-3.0-or-later
  12. // ==/UserScript==
  13.  
  14. "use strict";
  15.  
  16. document.querySelectorAll('article.post[typeof="Article"]').forEach(post => {
  17.  
  18. const modMeta = post.querySelector(':scope meta[property="dateModified"][content]');
  19. const pubTime = post.querySelector(':scope time');
  20. if (modMeta !== null && pubTime !== null) {
  21.  
  22. const dateTime = modMeta.content;
  23. const modDate = new Date(dateTime);
  24.  
  25. // if modDate is not Invalid Date
  26. // modDate.toString !== "Invalid Date"
  27. if (!Number.isNaN(modDate.getTime())) {
  28. const $ = tagName => document.createElement(tagName);
  29. const textContent = modDate.toLocaleDateString("en-US", { dateStyle: "long" });
  30. const modTime = Object.assign($("time"), { dateTime, textContent });
  31. pubTime.before(
  32. $("br"),
  33. "Published "
  34. );
  35. pubTime.after(
  36. " | Modified ",
  37. modTime,
  38. $("br")
  39. );
  40. }
  41.  
  42. }
  43.  
  44. });