New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discuss : possibility to execute standalone (callable in devtools) process ? #769
Comments
|
You can achieve this by:
const { content, title, filename } = await singlefile.getPageData({
removeImports: true,
removeScripts: true,
removeAudioSrc: true,
removeVideoSrc: true
});The variable Note however that you will need to disable CORS in order to be able to retrieve contents from external domains. Otherwise, it's also possible to pass a custom function used to fetch all the contents. This is how SingleFile solves this issue in the JSDOM implementation, see below SingleFile/cli/back-ends/jsdom.js Line 81 in 6b9b6df
SingleFile/cli/back-ends/jsdom.js Lines 87 to 107 in 6b9b6df
I hope this information is useful. Feel free to ask me more questions. |
|
Hi @gildas-lormeau (and yes, happy to see you again ;-)), This is perfect, this whole material is very helpful (and is working like a charm, just tested it). |
|
Great! (I edited the message because I wasn't 100% sure you were the right fcamblor ;-)). I am really glad to hear that SingleFile is useful to you. |
|
@gildas-lormeau Hello Gildas (and sorry to bother you again ! :-) ) I'm facing an issue on I tried to tweak a little bit the implementation (using I noticed there was a FYI, my altered Would you have any piece of advice to share on this ? |
|
That's a weird issue... It means the promise returned by if (xhrRequest.readyState == win.XMLHttpRequest.DONE) { If you can, I would also recommend to attach a debugger to the webview and check the network requests. |
|
Hello Gildas, I was doubly wrong ... SVG files were properly loaded (even with I just found the root cause of my issue : I was executing This was resulting into a silent error here, leading to a Sorry for the false positive and the inconvenience / useless noise. |
|
Hello Frédéric, No problem, I'm really glad to hear this was not in fact a weird issue and that you were able to identify and fix its root cause. A quick and dirty way to circumvent it could be to implement the missing FileReader.prototype.addEventListener = function(name, callback) { this["on" + name] = callback; };BTW, if it is possible (including in private if needed), I would be interested to know more about your use case, it sounds interesting :) |
|
That's exactly what I did, with a little difference :-) My use case is : I'm working on a web app aimed at translating web applications. One of the main features of this webapp is to be able to provide context to translators, and particularly "living apps" where translatable messages reside (that way, they are able to see in realtime if the translation they provided is going to break a screen or not) i18n.small.demo.movWhat I call a "living app" is typically a self-sufficient single HTML page that he can contribute to the translation app (the blue app in the video above) and this is where Given that we're working a lot with Cordova for our mobile apps, I need to make this work on cordova webviews as well, and this is now working since yesterday evening (or, let's say ... today early morning ;-)) |
|
That's a great use-case! It also sounds like a great user experience. This is not the first time that SingleFile is used in the translation field. Funny, I didn't anticipate it. Anyway, I hope SingleFile will bring you satisfaction. Good luck and don't hesitate to ping me if you need help. |
Is your feature request related to a problem? Please describe.
I was wondering if it was something doable to provide an importable module for
single-file, that could make it executable programmatically from DevTools (without having to install the extension)Something like :
(this is maybe something already existing / easily achievable, but didn't found it in the doc as the CLI is not matching my need here unfortunately, see in additional context section below)
Describe the solution you'd like
Publish a JS library providing API used to capture current page programmatically.
Additional context (optional)
The extension is fantastic, but in some cases, I would like to trigger it directly from devtools.
Typically, I need to capture HTML generated on an Android device webview (where I can't install the chrome extension, and where I can't get any URL that could be processed by the CLI).
I can remotely inspect the Android webview from my laptop, and can have access to the whole devtools context (including DOM, etc.) from it, but didn't found any way to remotely capture DOM content as single file.
With such standalone library, I assume this would become something feasible.
WDYT ?
(not sure if this would be that easy anyway, as any extension API would have to be avoided in that case)
The text was updated successfully, but these errors were encountered: