Android dark mode detection in pure Node.js - node.js

I would like to detect dark mode on my android device running Node.js from termux.
Also I can't use electron, phantom.js or any other "rendering" library.
Is it possible?
If not I will accept any other possibility to get the device theme, using termux.
Edit: I opened a request on the github page of termux-api

Related

How to create a browser instance (pupeeteer) with firebase and use it in my app (node.js)?

I created a firebase project. This communicates with a mobile application (node.js). As part of this project I want to use pupeeteer.
I have no problem launching functions using pupeeteer in firebase.
The problem is that I want to make the user perform actions. So I have to display the web page (pupeeteer) in the application via a browser generated by the server (with a firebase function?)?
However I have no idea how to launch a browser instance in the background and close it at the end of processing?
Can you help me ? Is this the right solution?
I want to use this :
This library does 2 things:
Download the chromium binaries and launch a Chromium process.
Connect to this process with Websocket and send json commands to control the browser.
Due to limitations on mobile platforms (iOS and Android), it is not possible to launch an external Chromium process on iOS and Android. So, step 1) does not work on mobile.
You can still use puppeteer-dart on Flutter either with:
Flutter on Desktop (macOS, windows, Linux)
Flutter on mobile BUT with the actual Chrome instance running on a server and accessed from the mobile app using puppeteer.connect
The pub.dev website reports that this library works with Android and iOS. The supported platform list is detected automatically and can't be manually modified to express the current limitations

Flutter desktop app for Linux - but Linux server not running desktop

Question: Is there any way to provide a terminal connection with a canvas to a Flutter app being hosted on a non-gui Linux server?
Context: We have a lot of character-based tools running on (CentOS) Linux server. It would be great to write them (or a wrapper around them) as GUI apps using Flutter. I don't need full window management, just things like GUI components, mouse text selection, cut-n-paste, drag-n-drop, SDI design UI.
Is there any way to accomplish that without installing desktop software on the server? I know there's a Raspberry Pi setup for flutter apps on Linux WITHOUT installing desktop. Would anything like that work?

How to listen to keyboard events on the system level via Node.js?

I play with CDP and Puppeteer libraries with Node.js. I want to capture keyboard event within browser window (not window or document objects at webpage context) context - so when I am in Chromium DevTools (runned by Puppeteer) and press i.e Ctrl + E combination (which fires Performance test in Timeline tab) I would like to capture this event.
I managed to do that with RobotJS library, but it does not support the latest Node version (v8.7), so after updating Node I cannot even install it. I found iohook lib, but it does not support latest Node neither as well as Windows (which I use).
CDP and Puppeeteer libs AFAIK supports only events within webpage context only.
I also tried Node native module readline, which however captures keyboard events in console, but not in browser window.
Is there any way to capture/listen to keyboard events in Chrome/Chromium browser window via Node.js?
iohook at this moment support Node.js 8+ but still don't have prebuilt versions for windows.
You can try use windows fork of iohook
Or you can compile original iohook in your windows machine

How to debug JavaScript code with mobile browsers

I know about firebug and the developer tools for the major modern desktop browsers, but I can't find any way of debugging JavaScript code on mobile browsers.
What are some high level techniques I can use to debug code on mobile browsers?
Android devices can be put into developer mode by going through settings>Phone status then tapping on "Build number" 7 times. This allows you to do a bunch of things (see step 5) including USB debugging. (Some devices might have Build number under Software Info)
To activate USB debugging, look in Settings for the newly appeared "{ } Developer Options", open this and switch on USB debugging. Connect your device using a direct USB connection.
In Chrome on your desktop, in the usual developer tools panel used for debugging, look in the menu for more tools>remote devices. With Discover USB devices selected, you should now see your mobile device on the side.
Select it to see a list of all the chrome tabs you have open and the ability to enter URLs directly.
Selecting one of the links will open up a new window with a mirror of your device screen on the left and all the familiar chrome debug tools on the right. You can still control your device directly or use the mouse on the mirrored screen. It even rotates.
full details on remote debugging from google and how to enable developer mode (link as above) from askvg.com
Android provides a tool set for these purposes:
https://developers.google.com/web/tools/chrome-devtools/remote-debugging/?utm_source=dcc&utm_medium=redirect&utm_campaign=2016q3
Apple does it a similar way:
https://developer.apple.com/safari/tools/
Tutorial: https://css-tricks.com/using-chrome-devtools-to-debug-javascript-in-any-browser-with-ghostlab-2/
You can debug on Safari Mobile with any iPhone/iPad. In Developer menu you can find your device and you can then debug your code with inspector.
If you have an Android Device instead, you can debug on Chrome Desktop (remember to active the debug mode) with chrome://inspect
On the IPhone you can go into settings>Safari>advanced and turn web inspector on
Sometimes I get bugs reported by customers that are not reproducible every time or in our testing. For such cases I recommend Lucky Orange. It records the user activity and also has the option to record console messages.
PS - I'm not an affiliate, I use them for my own projects and like it.
Another solution for basic debugging (which many times is all is needed), is having a console polyfill on mobile without the need to plug into USB on desktop.
mobileConsole is such a console polyfill.
Hope it helps someone, I found it useful.

Phonegap on iPhone 4 device

I have a PhoneGap app that works perfectly on the iPhone 3.2 simulator and also iPhone 3 and 3GS devices.
I have just downloaded and installed the latest iOS SDK, changed the settings in Project>Edit Project Settings to allow the application to work, and run it successfully within the iPhone 4 simulator and even the iPad simulator.
However when I run it on a provisioned iPhone 4 device, nothing seems to happen when I run it. I get the splash screen, but nothing happens after that. In the log I get this:-
2010-09-13 10:11:34.156 MyApp[89:307] Going to play default movie
2010-09-13 10:11:34.169 MyApp[89:307] Can't find filename default.mov in the app bundle
2010-09-13 10:11:34.948 MyApp[89:307] Device initialization: DeviceInfo = {"name":"iPhone","uuid":"548444a41eee3aec9dd66511e12e6a6b1b277a2a","platform":"iPhone","gap":"0.9.0","version":"4.0.2"};
2010-09-13 10:11:35.022 MyApp[89:307] Docs Path:/var/mobile/Applications/D887FEA7-0C56-4991-890F-E790361A9D64/Documents
2010-09-13 10:11:35.037 MyApp[89:307] Free space is 15497396224
And nothing else!!
Really annoying. Anybody know what might be happening here? I tried fiddling with a few settings in the Project Settings but that doesn't seem to have fixed it.
Any help would be really appreciated.
Regards
Nick
Update - my problem. I had some external javascript which was crashing due to the way I was calling it from the HTML file. Weird that it only affected the iPhone/iPad device but not the simulators, but there you go....

Resources