IGG-Games show last edit date

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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));
  
  })();