IGG-Games show last edit date

Show the last edit date of the game on IGG-Games

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         IGG-Games show last edit date
// @namespace    https://github.com/Alistair1231/my-userscripts/
// @version      0.0.5
// @description  Show the last edit date of the game on IGG-Games
// @author       Alistair1231
// @icon         https://icons.duckduckgo.com/ip2/igg-games.com.ico
// @grant        none
// @match        https://igg-games.com/*
// @license MIT
// ==/UserScript==
// https://openuserjs.org/scripts/Alistair1231/IGG-Games_show_last_edit_date
// https://greasyfork.org/en/scripts/468235-igg-games-show-last-edit-date
(async function() {

  function tryGetDate() {
      return new Promise((resolve, reject) => {
        const preDate = document.querySelector("article meta[property*='date']");
        if (preDate === null) {
          setTimeout(tryGetDate, 500);
        } else {
          resolve(preDate);
        }
      });
    }
  
  var preDate= await tryGetDate()
  
  var dateString = new Date(preDate.content).toLocaleDateString("en-US", {
  year: "numeric",
  month: "long",
  day: "numeric"
  });
  
  // element after heading
  var whereToAdd = document.querySelector("article.post h1").nextElementSibling;
  
  // reverse order because of prepend()
  var whatToAdd = [
      document.createElement('br'),
      document.createElement('br'),
      `(last update ${dateString})`,
  ];
  whatToAdd.forEach(x => whereToAdd.prepend(x));
  
  })();