Send navigate events to client module
This commit is contained in:
parent
e1932b7f74
commit
ba4ba87eec
|
@ -66,6 +66,12 @@ class Comms {
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
send(channel, message) {
|
||||||
|
return _asyncToGenerator(function* () {
|
||||||
|
BDIpc.send(channel, message);
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class BetterDiscord {
|
class BetterDiscord {
|
||||||
|
@ -86,31 +92,26 @@ class BetterDiscord {
|
||||||
_this.windowUtils = new WindowUtils({ window });
|
_this.windowUtils = new WindowUtils({ window });
|
||||||
|
|
||||||
//Log some events for now
|
//Log some events for now
|
||||||
_this.windowUtils.webContents.on('did-start-loading', function (e) {
|
//this.windowUtils.webContents.on('did-start-loading', e => this.windowUtils.executeJavascript(`console.info('did-start-loading');`));
|
||||||
return _this.windowUtils.executeJavascript(`console.info('did-start-loading');`);
|
//this.windowUtils.webContents.on('did-stop-loading', e => this.windowUtils.executeJavascript(`console.info('did-stop-loading');`));
|
||||||
});
|
//this.windowUtils.webContents.on('did-get-response-details', e => this.ignite(this.windowUtils.window));
|
||||||
_this.windowUtils.webContents.on('did-stop-loading', function (e) {
|
//this.windowUtils.webContents.on('page-favicon-updated', e => this.windowUtils.executeJavascript(`console.info('page-favicon-updated');`));
|
||||||
return _this.windowUtils.executeJavascript(`console.info('did-stop-loading');`);
|
//this.windowUtils.webContents.on('will-navigate', e => this.windowUtils.executeJavascript(`console.info('will-navigate');`));
|
||||||
});
|
//this.windowUtils.webContents.on('did-navigate', e => this.windowUtils.executeJavascript(`console.info('did-navigate');`));
|
||||||
_this.windowUtils.webContents.on('did-get-response-details', function (e) {
|
//this.windowUtils.webContents.on('did-navigate-in-page', e => this.windowUtils.executeJavascript(`console.info('did-navigate-in-page');`));
|
||||||
|
//this.windowUtils.webContents.on('did-finish-load', e => this.injectScripts(true));
|
||||||
|
|
||||||
|
_this.windowUtils.events('did-get-response-details', function () {
|
||||||
return _this.ignite(_this.windowUtils.window);
|
return _this.ignite(_this.windowUtils.window);
|
||||||
});
|
});
|
||||||
_this.windowUtils.webContents.on('page-favicon-updated', function (e) {
|
_this.windowUtils.events('did-finish-load', function (e) {
|
||||||
return _this.windowUtils.executeJavascript(`console.info('page-favicon-updated');`);
|
|
||||||
});
|
|
||||||
_this.windowUtils.webContents.on('will-navigate', function (e) {
|
|
||||||
return _this.windowUtils.executeJavascript(`console.info('will-navigate');`);
|
|
||||||
});
|
|
||||||
_this.windowUtils.webContents.on('did-navigate', function (e) {
|
|
||||||
return _this.windowUtils.executeJavascript(`console.info('did-navigate');`);
|
|
||||||
});
|
|
||||||
_this.windowUtils.webContents.on('did-navigate-in-page', function (e) {
|
|
||||||
return _this.windowUtils.executeJavascript(`console.info('did-navigate-in-page');`);
|
|
||||||
});
|
|
||||||
_this.windowUtils.webContents.on('did-finish-load', function (e) {
|
|
||||||
return _this.injectScripts(true);
|
return _this.injectScripts(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_this.windowUtils.events('did-navigate-in-page', function (event, url, isMainFrame) {
|
||||||
|
_this.windowUtils.send('did-navigate-in-page', { event, url, isMainFrame });
|
||||||
|
});
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
if (__DEV) {
|
if (__DEV) {
|
||||||
_this.injectScripts();
|
_this.injectScripts();
|
||||||
|
|
|
@ -153,6 +153,15 @@ class WindowUtils extends Module {
|
||||||
if (variable) this.executeJavascript(`${variable} = require("${fpath}");`);else this.executeJavascript(`require("${fpath}");`);
|
if (variable) this.executeJavascript(`${variable} = require("${fpath}");`);else this.executeJavascript(`require("${fpath}");`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
events(event, callback) {
|
||||||
|
this.webContents.on(event, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
send(channel, message) {
|
||||||
|
channel = channel.startsWith('bd-') ? channel : `bd-${channel}`;
|
||||||
|
this.webContents.send(channel, message);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
|
@ -65,6 +65,10 @@ class Comms {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async send(channel, message) {
|
||||||
|
BDIpc.send(channel, message);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class BetterDiscord {
|
class BetterDiscord {
|
||||||
|
@ -82,14 +86,22 @@ class BetterDiscord {
|
||||||
this.windowUtils = new WindowUtils({ window });
|
this.windowUtils = new WindowUtils({ window });
|
||||||
|
|
||||||
//Log some events for now
|
//Log some events for now
|
||||||
this.windowUtils.webContents.on('did-start-loading', e => this.windowUtils.executeJavascript(`console.info('did-start-loading');`));
|
//this.windowUtils.webContents.on('did-start-loading', e => this.windowUtils.executeJavascript(`console.info('did-start-loading');`));
|
||||||
this.windowUtils.webContents.on('did-stop-loading', e => this.windowUtils.executeJavascript(`console.info('did-stop-loading');`));
|
//this.windowUtils.webContents.on('did-stop-loading', e => this.windowUtils.executeJavascript(`console.info('did-stop-loading');`));
|
||||||
this.windowUtils.webContents.on('did-get-response-details', e => this.ignite(this.windowUtils.window));
|
//this.windowUtils.webContents.on('did-get-response-details', e => this.ignite(this.windowUtils.window));
|
||||||
this.windowUtils.webContents.on('page-favicon-updated', e => this.windowUtils.executeJavascript(`console.info('page-favicon-updated');`));
|
//this.windowUtils.webContents.on('page-favicon-updated', e => this.windowUtils.executeJavascript(`console.info('page-favicon-updated');`));
|
||||||
this.windowUtils.webContents.on('will-navigate', e => this.windowUtils.executeJavascript(`console.info('will-navigate');`));
|
//this.windowUtils.webContents.on('will-navigate', e => this.windowUtils.executeJavascript(`console.info('will-navigate');`));
|
||||||
this.windowUtils.webContents.on('did-navigate', e => this.windowUtils.executeJavascript(`console.info('did-navigate');`));
|
//this.windowUtils.webContents.on('did-navigate', e => this.windowUtils.executeJavascript(`console.info('did-navigate');`));
|
||||||
this.windowUtils.webContents.on('did-navigate-in-page', e => this.windowUtils.executeJavascript(`console.info('did-navigate-in-page');`));
|
//this.windowUtils.webContents.on('did-navigate-in-page', e => this.windowUtils.executeJavascript(`console.info('did-navigate-in-page');`));
|
||||||
this.windowUtils.webContents.on('did-finish-load', e => this.injectScripts(true));
|
//this.windowUtils.webContents.on('did-finish-load', e => this.injectScripts(true));
|
||||||
|
|
||||||
|
this.windowUtils.events('did-get-response-details', () => this.ignite(this.windowUtils.window));
|
||||||
|
this.windowUtils.events('did-finish-load', e => this.injectScripts(true));
|
||||||
|
|
||||||
|
this.windowUtils.events('did-navigate-in-page', (event, url, isMainFrame) => {
|
||||||
|
this.windowUtils.send('did-navigate-in-page', { event, url, isMainFrame });
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (__DEV) { this.injectScripts(); }
|
if (__DEV) { this.injectScripts(); }
|
||||||
|
|
|
@ -136,6 +136,15 @@ class WindowUtils extends Module {
|
||||||
if (variable) this.executeJavascript(`${variable} = require("${fpath}");`);
|
if (variable) this.executeJavascript(`${variable} = require("${fpath}");`);
|
||||||
else this.executeJavascript(`require("${fpath}");`);
|
else this.executeJavascript(`require("${fpath}");`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
events(event, callback) {
|
||||||
|
this.webContents.on(event, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
send(channel, message) {
|
||||||
|
channel = channel.startsWith('bd-') ? channel : `bd-${channel}`;
|
||||||
|
this.webContents.send(channel, message);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue