magical-girls-runa-and-nanami/js/plugins/OpenExternalLink.js
2026-02-28 12:33:13 -06:00

70 lines
2.4 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*=============================================================================
OpenExternalLink.js
----------------------------------------------------------------------------
(C)2023 Triacontane
This software is released under the MIT License.
http://opensource.org/licenses/mit-license.php
----------------------------------------------------------------------------
Version
1.0.0 2023/05/08 初版
----------------------------------------------------------------------------
[Blog] : https://triacontane.blogspot.jp/
[Twitter]: https://twitter.com/triacontane/
[GitHub] : https://github.com/triacontane/
=============================================================================*/
/*:
* @plugindesc 外部リンクを開くプラグイン
* @target MZ
* @url https://github.com/triacontane/RPGMakerMV/tree/mz_master/OpenExternalLink.js
* @base PluginCommonBase
* @orderAfter PluginCommonBase
* @author トリアコンタン
*
* @command OPEN
* @text リンクを開く
* @desc 指定したURLを既定のブラウザで開きます。
*
* @arg url
* @text URL
* @desc 開くURLです。
* @default
* @type string
*
* @help OpenExternalLink.js
*
* 指定したURLを既定のブラウザで開きます。
* プラグインコマンドから実行してください。
* 
* このプラグインの利用にはベースプラグイン『PluginCommonBase.js』が必要です。
* 『PluginCommonBase.js』は、RPGツクールMZのインストールフォルダ配下の
* 以下のフォルダに格納されています。
* dlc/BasicResources/plugins/official
*
* 利用規約:
* 作者に無断で改変、再配布が可能で、利用形態商用、18禁利用等
* についても制限はありません。
* このプラグインはもうあなたのものです。
*/
(() => {
'use strict';
const script = document.currentScript;
PluginManagerEx.registerCommand(script, 'OPEN', function(args) {
this.openExternalLink(args.url);
});
Game_Interpreter.prototype.openExternalLink = function(url) {
if (!Utils.isNwjs()) {
window.open(url);
} else {
const exec = require('child_process').exec;
if (process.platform === 'darwin') {
exec('open "" "' + url + '"' );
} else {
exec('start "" "' + url + '"');
}
}
};
})();