Last updated for App Store apps

Add information about when the app was last updated to the product information.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Last updated for App Store apps
// @namespace    https://github.com/fnurl/userscripts
// @version      0.1.2
// @description  Add information about when the app was last updated to the product information.
// @author       @fnurl
// @match        https://itunes.apple.com/*
// @license      MIT
// ==/UserScript==

(function() {
  'use strict';
  // wait until everything has loaded
  $(window).bind("load", function() {
    // add an additional wait as workaround for text disappearing when loading for the first time
    var timeout = 500;
    window.setTimeout(function() {
      // Localized labels
      var lang = {
                   "sv": "Senaste",
                   "en": "Latest",
                 };
      // Localized label string
      var updatedText;

      // Localization for defined presets
      var locale = $("html").attr("lang").match("..");
      //var locale = window.location.pathname.match("/(.*?)/.*")[1];
      if (lang.hasOwnProperty(locale)) {
        updatedText = lang[locale];
      }
      else {
        // Localized update history string for other locales
        updatedText = $(".version-history__headline").text();
      }

      // Info about the last version
      var lastVersion = $(".whats-new__latest").first();
      var versionNumber = lastVersion.find('[class$="__latest__version"]').text();
      var versionDate = lastVersion.find("time").attr("datetime");

      // Product info element
      var productHeaderList = $("header .product-header__list").first();

      // Prepare info about last version and add it to the product info
      var lastUpdatedListItem = '<li class="product-header__list__item">' +
                                updatedText + ': ' +
                                versionNumber + ' (' + versionDate + ')' +
                                '</li>';
      productHeaderList.append(lastUpdatedListItem);
    }, timeout);
  });
})();