I want to capture a screenshot of a file:// URI with minimal window decorations for the undermentioned:
Consequently, I have attempted to:
Invoke a bookmark containing javascript:window.open(location.href, "detab", "toolbar=0"); window.close() on the URI, to no avail.
Hardcode the URI like javascript:window.open("file:///home/RokeJulianLockhart/Downloads/@%7B'Name'='Curriculum%20Vit%C3%A6'%7D%23.PDF", "detab", "toolbar=0"); window.close(), to no avail.
Enter a custom HTML file:
Invoke it in the console (to no avail):
22:15:05.436 Uncaught Error: Access to 'file:///home/RokeJulianLockhart/Downloads/@%7B'Name'='Curriculum%20Vit%C3%A6'%7D%23.PDF' from script denied
<anonymous> debugger eval code:1
debugger eval code:1:8
Provide the aforementioned as a CLI argument, [1] to no avail.
How can I accomplish this?
Comparison
This executes in google-chrome-canary-136.0.7069.0-1.x86_64:
Works for me on Firefox Nightly 138.0a1 (2025-03-16) (64-bit) and Chromium Version 136.0.7073.0 (Developer Build) (64-bit), both from today.
In Nightly I always set security.fileuri.strict_origin_policy to false. On Chromium I have several command line switches set, including --allow-file-access-from-files.
Looks like your screenshot is of a chrome-extension: protocol URL, not a file: URL.
You can set relevant Web extension permissions is manifest.json, .e.g.,
If you are really on a chrome-extension: URL - and it’s your unpacked extension - you can set windows permissions use chrome.windows.create() with options, among other approaches.
I think Firefox implements windows Web extension API, too.
@guest271314, that didn’t modify the beheaviour for me in firefox-136.0.1-1.fc41.x86_64. Does it require a browser restart, or anything else unintuitive?
Unfortunately, this doesn’t matter much, since Chrome already allows the JS to run, it merely doesn’t interpret it correctly, because it creates a tab instead of a window (as aforementioned).
@guest271314, what do you refer to by “your unpacked extension” – what extension? How could I be on a chrome-extension-schema-prefixed URI when I see file in the omnibox, and I’m looking at the native PDFJS implementation? [1]
What I would do is get the source code of the extension and load the extension in Chrome as an unpacked extension on chrome://extensions. Then the folder will be wherever you downloaded the source folder to.
That works for HTML files, but is blocked on the PDFJS GUI.
We’ll, if you are using a Web extension, use another Web extension to override the former and do whatever you want.
I don’t know what you mean about PDFJS GUI.
The original question appeared to me about opening a local file on file: URL in a popup window.
You’ll have to dive in about:config and hack around to try to get Firefox to behave similar to Chrome, in various ways. And vice versa. Might be possible, might not be possible.
@guest271314, a PDF file. These are treated specially: they are always invoked in the PDFJS GUI, which is included with Chrome and Firefox! Whether it’s an extension or not under-the-hood is an implementation detail, because it isn’t removable, and isn’t even exposed to the user as an extension. One of my previous SO citations explained this:
Consequently:
I’ll try that, if I’m able to. It might work, if it integrates with about:preferences#general:~:text=Applications when loaded like any normal extension:
Summarily, I want window.open(location.href, "detab", "toolbar=0") to operate on file:// URIs for PDF files, like it does on HTML files (whether served via moz-extension:, about:, file, or https).
@guest271314, a PDF file. These are treated specially: they are always invoked in the PDFJS GUI, which is included with Chrome and Firefox ! Whether it’s an extension or not under-the-hood is an implementation detail, because it isn’t removable, and isn’t even exposed to the user as an extension. One of my previous SO citations explained this:
I don’t know who told you that. I do whatever i want on Chromium. By any means necessary.
Summarily, I want window.open(location.href, "detab", "toolbar=0") to operate on file:// URIs for PDF files, like it does on HTML files.
I demonstrated that is possible, above.
If you want to do that from arbitrary URL’s, file:, http:, whatever, then I would suggest writing an extension. Firefox tries to block all kinds of programmatic usages in DevTools.