Skip to content

Instantly share code, notes, and snippets.

@ArcCosine
Last active February 8, 2018 06:49
Show Gist options
  • Save ArcCosine/a10fe5b460dd068a2a13beef1ba8426b to your computer and use it in GitHub Desktop.
Save ArcCosine/a10fe5b460dd068a2a13beef1ba8426b to your computer and use it in GitHub Desktop.
javascript:(
() => {
'use strict';
const getLastUpdate = domObj => {
return domObj.querySelector(".contributors-sub time").dateTime;
};
//XMLHttpRequestで英語版MDNを取得
fetch("https://developer.mozilla.org" + location.pathname.replace(/\/ja\//, "/en-US/"))
.then( response => {
return response.text();
})
.then( resText => {
const parser = new DOMParser();
//英語版MDNページの最終更新日を取得
const enlastmod = getLastUpdate(parser.parseFromString(resText, "text/html"));
//現在の日本語版MDNページの最終更新日を取得
const jalastmod = getLastUpdate(document);
const message = (Date.parse(jalastmod) - Date.parse(enlastmod) < 0 ) ? `${jalastmod} :ja\n${enlastmod} :en\n日本語の情報が古いです。` : "☺";
window.alert(message);
});
}
)();
@ArcCosine
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment