Skip to content
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

Release addon as bookmarklet #1597

Open
fekir opened this issue Oct 19, 2024 · 6 comments
Open

Release addon as bookmarklet #1597

fekir opened this issue Oct 19, 2024 · 6 comments

Comments

@fekir
Copy link

fekir commented Oct 19, 2024

Is your feature request related to a problem? Please describe.

As far as I've experienced, SingleFile does a very good job at saving webpages locally.

The main issue is that SingleFile has access to all the pages I'm looking at, even when I'm not using it.

Describe the solution you'd like

As an end user, without looking at the source code of SingleFile, I would like to be sure that SingleFile cannot access any content unless I've executed it.
And if I execute it, that it can only access the current of the page/tab I'm looking at.

I believe that the following could be a possible solution: create a bookmarklet containing the current functionality of SingleFile.

Bookmarklets are inactive unless the user executes them, and if executed, it has access only on the current page.
Both restrictions are enforced by the browser, thus I do not need to trust the current implementation of SingleFile.

Describe alternatives you've considered (optional)

Keep the add-on disabled, enable it the moment I need it, and then disable it again.
But it is easy to forget to disable the add-on again.

An alternative solution is to use a different Firefox profile, but it is impractical, especially if the webpage is ephemeral, and one might not be able to open it again in the second profile.

Additional context (optional)

Since bookmarklets cannot be configured/are stateless, a dialog should be shown when the bookmarklet is started, asking if the current configuration is fine for the current operation.

@gildas-lormeau
Copy link
Owner

On paper, it should be possible to run SingleFile in a bookmarklet. The problem is that the quality of the result will vary greatly. These days, it's very common for resources (stylesheets, images, fonts, etc.) to be blocked for bookmarklets, due to the “Same Origin Policy” (SOP). As a result, the resulting page is likely to be severely degraded. In order to bypass the SOP, SingleFile can only work in the context of web extensions or from the command line interface, by injecting scripts into the browser.

@fekir
Copy link
Author

fekir commented Oct 21, 2024

At least on Firefox (but I believe other browsers too), bookmarklets bypasses CSP policies (https://bugzilla.mozilla.org/show_bug.cgi?id=1478037), so I'm not sure how big this issue is.

Otherwise a server that sets a website with csp that javascript is not allowed would not be able to execute any bookmarklet, even something simple like

javascript:(function(){location.href='https://jigsaw.w3.org/css-validator/validator?uri='+location.href;})();

In case I misunderstood you, do you have a minimal example I could test?

@gildas-lormeau
Copy link
Owner

Thank you, I'll have to take a closer look, but I'd be very surprised to learn that the SOP isn't applied in the bookmarklet context.

@gildas-lormeau
Copy link
Owner

I did a test and I confirm the Same Origin Policy cannot be bypassed when running a bookmarklet. This is the test I did:

  1. Create a bookmark with javascript:fetch("https://www.example.com").then(r => r.text()) as URL
  2. Go to any site except https://www.example.com
  3. Execute the bookmarklet
  4. An error is displayed in the console

@fekir
Copy link
Author

fekir commented Oct 24, 2024

Thank you for the feedback.

Seems that not all csp policies are ignored.

Does SingleFile need to download files that the website itself does not download?
If it does (would like to know why, I did not expect it), then it is surely an issue.

I also find it strange that an extension has more "power" than the developer console, as

fetch("https://www.example.com");

fails (for example), on the github website.

@th
Copy link

th commented Nov 18, 2024

A bookmarklet would also be very interesting because company-managed web browsers usually do not allow the installation of add-ons.

But I‘m not surprised that security measures preclude the viability of a bookmarklet. Still, even limited functionality would be an advantage in an enterprise context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants