「最新版を確認」の版間の差分
ナビゲーションに移動
検索に移動
空行の除去 |
→ソース: URLの修正 |
||
| 12行目: | 12行目: | ||
// Copyright (c) 2016 diaphragm | // Copyright (c) 2016 diaphragm | ||
// Released under the MIT license | // Released under the MIT license | ||
// | // https://opensource.org/license/mit/ | ||
// ----------------------------------------------------------------------------- | // ----------------------------------------------------------------------------- | ||
// | // スクリプトを使用したデータの取得 (Windows) | ||
// https:// | // https://learn.microsoft.com/ja-jp/windows/win32/winhttp/retrieving-data-using-script | ||
function getText(strURL) | function getText(strURL) | ||
{ | { | ||
| 54行目: | 54行目: | ||
// ピリオド区切りバージョン番号の比較 | Life is Real. | // ピリオド区切りバージョン番号の比較 | Life is Real. | ||
// https://ptsv. | // https://ptsv.jp/2015/09/01/ピリオド区切りバージョン番号の比較/ | ||
function version(a,op,b) | function version(a,op,b) | ||
{ | { | ||
2023年7月1日 (土) 17:48時点における版
Meryの最新版の有無を( https://www.haijin-boys.com/rss.xml )から確認します。
「イベントで実行」を設定しておけば自動的に確認することが出来ますが、 「スクロールした時」など頻繁に実行されるイベントを設定するとサーバーに優しくないので 「アクティブな文書が変更された時」などがおすすめです。
ソース
// -----------------------------------------------------------------------------
// 最新版を確認
//
// Copyright (c) 2016 diaphragm
// Released under the MIT license
// https://opensource.org/license/mit/
// -----------------------------------------------------------------------------
// スクリプトを使用したデータの取得 (Windows)
// https://learn.microsoft.com/ja-jp/windows/win32/winhttp/retrieving-data-using-script
function getText(strURL)
{
var strResult;
try
{
// Create the WinHTTPRequest ActiveX Object.
var WinHttpReq = new ActiveXObject(
"WinHttp.WinHttpRequest.5.1");
// Create an HTTP request.
var temp = WinHttpReq.Open("GET", strURL, false);
// Send the HTTP request.
WinHttpReq.Send();
// Retrieve the response text.
strResult = WinHttpReq.ResponseText;
}
catch (objError)
{
strResult = objError + "\n"
strResult += "WinHTTP returned error: " +
(objError.number & 0xFFFF).toString() + "\n\n";
strResult += objError.description;
}
// Return the response text.
return strResult;
}
//window.alert(getText("http://www.microsoft.com/default.htm"));
// ピリオド区切りバージョン番号の比較 | Life is Real.
// https://ptsv.jp/2015/09/01/ピリオド区切りバージョン番号の比較/
function version(a,op,b)
{
a = a.split('.');
b = b.split('.');
var ia,ib;
var limit = Math.max(a.length,b.length);
while(limit--)
{
ia = parseInt(a.shift() || 0);
ib = parseInt(b.shift() || 0);
if(ia != ib)
break;
}
return eval([ia,op,ib].join(' '));
}
function checkUpdate(){
var rss_uri = 'https://www.haijin-boys.com/rss.xml';
var res = getText(rss_uri);
var m = res.replace(/[\n\r]/g,"").match(/<title>Mery\s*(\d+\.\d+\.\d+)<\/title>.*?<link>(.+?)<\/link>/);
var new_version = m[1];
var new_uri = m[2];
if(version(Editor.Version, "<", new_version)){
var mes = "新しいバージョン(" + new_version + ")があるようです。\nWebサイトを開きますか?";
if(confirm(mes)){
var Shell = new ActiveXObject("WScript.Shell");
Shell.Run(new_uri);
}
}
}
try{
checkUpdate();
}catch(e){
// nothing to do
}
スポンサーリンク