Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've used and tested, for a month, my fork of the extension containing a lot of changes. During this period I tested improvements for the following goals:
Also, to better understand the extension, I've added more documentation about cases and why it does some things a certain way.
For point 1 I've improved the
shouldCompress.js
with cases I came across. At the time of writing, I've used my fork for 32 days with the compression level set to 20% and have reached the following statistics: 55,747 images processed and 2.24GB data saved (91%). There is one case not added to this PR that catches more images: some images have a content type ofapplication/octet-stream
(example page: https://code.google.com/archive/p/repo-clean/).Point 2, was tackled by also checking if the current page is from a private network or has a different protocol (for pages like
about:config
etc.).Point 3, seems to be resolved. During my 32 days, I've never caught the bug. Before I caught it within two weeks. More testing is needed. The problem, from my debugging a lot, seems to originate from attaching and detaching the listeners. In this PR, I attach the listeners once on startup and keep it that way. It does use a bit more memory and CPU when disabled (since it still listens to images). But, this only minimally since we exit early in the
onBeforeRequest
listener by checking if the extension is enabled. If the extension is disabled/removed by the user, the browser will clean up automatically (tested by adding debug points and disabling/removing the extension).