2019-06-15 00:17:16 +10:00
|
|
|
var electron = require("electron");
|
2019-06-15 02:05:53 +10:00
|
|
|
const shell = electron.shell;
|
2019-06-15 00:17:16 +10:00
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
onmessage = function (e) {
|
|
|
|
if (e.data[0] == "openUrl") {
|
2019-06-15 02:05:53 +10:00
|
|
|
urls = e.data[1].match(/https?:\/\/(.+)/);
|
|
|
|
if (urls) {
|
2019-06-15 02:01:07 +10:00
|
|
|
shell.openExternal(e.data[1]);
|
|
|
|
}
|
2019-06-15 00:21:08 +10:00
|
|
|
} else if (e.data[0] == "sendSinmpleIpc") {
|
|
|
|
ipc.send(e.data[1], "")
|
2019-06-15 01:54:44 +10:00
|
|
|
} else if (e.data[0] == "dialogStore") {
|
|
|
|
ipc.send("dialogStore", e.data[1])
|
2019-06-15 02:10:32 +10:00
|
|
|
} else if (e.data[0] == "bmpImage") {
|
|
|
|
ipc.send('bmp-image', e.data[1]);
|
2019-06-15 00:17:16 +10:00
|
|
|
}
|
|
|
|
}
|
2019-06-15 01:51:41 +10:00
|
|
|
//version.js
|
2019-06-15 00:25:27 +10:00
|
|
|
ipc.send("getPlatform", "")
|
|
|
|
ipc.on('platform', function (event, arg) {
|
2019-06-15 02:05:53 +10:00
|
|
|
localStorage.setItem("platform", arg)
|
2019-06-15 00:25:27 +10:00
|
|
|
})
|
2019-06-15 01:51:41 +10:00
|
|
|
ipc.on('winstore', function (event, arg) {
|
2019-06-15 02:05:53 +10:00
|
|
|
localStorage.setItem("winstore", arg)
|
2019-06-15 01:51:41 +10:00
|
|
|
})
|
|
|
|
|
2019-06-15 00:17:16 +10:00
|
|
|
ipc.on('reload', function (event, arg) {
|
|
|
|
location.reload();
|
|
|
|
})
|
|
|
|
ipc.on('mess', function (event, arg) {
|
|
|
|
if (arg == "unzip") {
|
|
|
|
if (lang == "ja") {
|
|
|
|
$("body").text("アップデートを展開中です。");
|
|
|
|
} else {
|
|
|
|
$("body").text("Unzipping...");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
//Native Notf
|
|
|
|
ipc.on('shownotf', function (event, args) {
|
|
|
|
if (args["type"] == "toot") {
|
|
|
|
details(id, acct_id)
|
|
|
|
} else if (args["type"] == "userdata") {
|
|
|
|
udg(user, acct_id)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
function nano() {
|
|
|
|
ipc.send('nano', "");
|
|
|
|
}
|
2019-06-15 02:10:32 +10:00
|
|
|
//first.js
|
|
|
|
ipc.on('custom-css-response', function (event, arg) {
|
|
|
|
if (arg == "") { return false; }
|
|
|
|
var styleNode = document.createElement("style");
|
|
|
|
styleNode.setAttribute("type", "text/css")
|
|
|
|
|
|
|
|
var content = document.createTextNode(arg)
|
|
|
|
styleNode.append(content)
|
|
|
|
document.getElementsByTagName("head")[0].append(styleNode)
|
|
|
|
})
|
|
|
|
ipc.on('theme-css-response', function (event, arg) {
|
|
|
|
if (arg == "") { return false; }
|
|
|
|
var styleNode = document.createElement("style");
|
|
|
|
styleNode.setAttribute("type", "text/css")
|
|
|
|
|
|
|
|
var content = document.createTextNode(arg)
|
|
|
|
styleNode.append(content)
|
|
|
|
document.getElementsByTagName("head")[0].append(styleNode)
|
|
|
|
})
|
|
|
|
//img.js
|
|
|
|
ipc.on('bmp-img-comp', function (event, b64) {
|
|
|
|
media(b64[0], "image/png", b64[1]);
|
|
|
|
});
|
2019-06-15 01:51:41 +10:00
|
|
|
/*
|
2019-06-15 00:17:16 +10:00
|
|
|
var webviewDom = document.getElementById('webview');
|
|
|
|
const {
|
|
|
|
shell
|
|
|
|
} = require('electron');
|
|
|
|
webviewDom.addEventListener('new-window', function (e) {
|
|
|
|
shell.openExternal(e.url);
|
2019-06-15 01:51:41 +10:00
|
|
|
});
|
|
|
|
*/
|