2015-07-05 06:08:13 +00:00
|
|
|
/**
|
2016-01-22 11:57:39 +00:00
|
|
|
Preload file that will be executed in the renderer process
|
2015-07-05 06:08:13 +00:00
|
|
|
*/
|
|
|
|
|
2016-01-19 03:28:04 +00:00
|
|
|
var ipc = require('electron').ipcRenderer;
|
2015-07-05 06:08:13 +00:00
|
|
|
|
2016-01-22 18:44:42 +00:00
|
|
|
// monkeypatch window.Notification
|
|
|
|
hookNotify(function(title, opt){
|
|
|
|
ipc.emit('notification', title, opt);
|
|
|
|
});
|
|
|
|
|
2016-01-21 17:32:21 +00:00
|
|
|
document.addEventListener("DOMContentLoaded", function(event) {
|
2016-01-22 18:48:04 +00:00
|
|
|
// do things
|
2016-01-21 17:32:21 +00:00
|
|
|
});
|
2016-01-19 12:26:19 +00:00
|
|
|
|
|
|
|
ipc.on('params', function (event, message) {
|
2015-07-05 06:08:13 +00:00
|
|
|
var appArgs = JSON.parse(message);
|
2016-01-22 11:57:39 +00:00
|
|
|
console.log('nativefier.json', appArgs);
|
2016-01-19 12:26:19 +00:00
|
|
|
});
|
2016-01-22 18:44:42 +00:00
|
|
|
|
|
|
|
function hookNotify(cb){
|
|
|
|
var oldNotify = window.Notification;
|
|
|
|
var newNotify = function (title, opt) {
|
|
|
|
cb(title, opt);
|
|
|
|
return new oldNotify(title, opt);
|
|
|
|
};
|
|
|
|
newNotify.requestPermission = oldNotify.requestPermission.bind(oldNotify);
|
|
|
|
Object.defineProperty(newNotify, 'permission', {
|
|
|
|
get: function() {
|
|
|
|
return oldNotify.permission;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
window.Notification = newNotify;
|
|
|
|
}
|