Basecamp3 Chrome-extensions 'turbolinks:load' not firing - google-chrome-extension

console.log('messages-list script loaded');
document.addEventListener('turbolinks:load', function(){
console.log('turbolinks:load');
});
I'm trying to listen to this event but it is not firing in my script.js.
If I paste this in console of chrome browser then it works. Only first console.log statement works.

Related

How to send a message from puppeteer to a chrome extension?

I wrote a chrome extension that recording a screen by using chrome.tabCapture API. I want to be able to start and stop recording by using puppeteer.
Starting a recording was an easy part because I need to start it from the beginning - I'm just sending a message from the content script:
setTimeout(function(){
chrome.runtime.sendMessage({ action: "START_CAPTURING"}, function(response) {});
}, 100);
Now, I can't figure out how can I send a message from puppeteer to the background script to stop the capturing.
I tried to add a button to the page and waiting for the click event inside the content script:
var button = document.getElementById("stopBtn");
button.addEventListener("click", function() {
chrome.runtime.sendMessage({ action: "STOP_CAPTURING"}, function(response) {});
}, false);
It works. The problem with this approach is that even if I'm the owner of the content and able to add an additional element just for sake of
recording, it seems to me not an elegant solution.
I would expect to be able to send messages from puppeteer to extensions or calling functions declared in there.

use socket.io in chrome extension

Actually i want use socket on chrome extension.Connection should start when i open tab and it will get disconnect until chrome will get close now if i will create socket connection on content script then every time socket will get disconnect and connect again when page will get refresh so that
I have created connection on background script.
background script code:
chrome.tabs.onCreated.addListener(function callback(tabId, info){
socket = io.connect('http://localhost:3000');
});
Now i want to use same socket on content script..
for this i have made a callback on chrome.runtime.onMessage.addListener.
Callback request has came at content script but emit and on doesn't work
background script code:
chrome.runtime.onMessage.addListener( (request, sender, sendResponse)=> {
sendResponse(JSON.stringify(socket))
})

Is there a way to log everything from console.log in an Electron app using electon-log?

I already have a ton of console.log statement thru out the main process of my Electron app, is there a way to send all of those to electron-log or another log that can be access after the app is packaged? I was going to go thru and add log.error thru out the script, but hoping there is a better way.
console.log('this error', error)
log.error('this error:', error)
Something like:
console.log = function(){
...your code...
};
Can be an idea?

Unable to close serial port in nodejs

I'm using node-serialport available here.
Open the port and reading works very well, however I am unable to close the port.
I use the following code for that:
myserialport.on('close', function (err) {
console.log('port closed', err);
});
The callback function is never executed (no console output).
Can anyone, please show me the way?
I would like to be able to close one port and open another if needed or just close the port if user changes the page.
Jan
You can use the .close() method to instruct the serial port to close:
myserialport.close(function (err) {
console.log('port closed', err);
});
.on('close') allows you to add the function as a listener of the 'close' event. But, it will simply wait for the event to occur (to be emitted) rather than instruct it to be done.

socket.io-client and webpage

This is probably a very simple thing, but I can't figure it out as I'm relatively new to this. I have a server with an index.html page running great on nodejitsu. It works fine with no issues at all. However, I also have another node.js utilising socket.io-client. It's connecting fine and doing what I want it to do, but I'd like to incorporate an HTML page with it so I can control it with a click of a button. Essentially, I am trying to get my nodejitsu server page to refresh with a click of a button on my socket.io-client page. Here's the code on my client:
var io = require('socket.io-client'),
socket = io.connect('http://danturner81.server.jit.su', {port: 80});
socket.on('connect', function () { console.log("socket connected"); });
socket.on('disconnect', function () { console.log("socket disconnected"); });
socket.send('refreshScreen');
When I start this node via the terminal, it refreshes the page at danturner81.server.jit.su just fine. How would I incorporate this into a webpage with a button that executes the 'socket.send'?
Sorry if this appears dumb, but I really can't figure it out and I know I'm close to getting where I want!
Regards
Dan

Resources