This branch refactors out the response processing machinery, except for the script analysis/editing details left to a client callback, into a ResponseProcessor module which:
shields the webRequest and StreamFilter API details;
automatically selects HTML documents and scripts for processing, skipping other kinds of resources loaded as main_frame or sub_frame and therefore reducing the risk of breaking them;
handles character sets as gracefully as possible, by properly configuring the TextDecoder for the declared encoding and by forcing UTF-8 on output if necessary*
* The TextEncoder native Web API in its current specification dropped support for any encoding except UTF-8: therefore when using it to edit the response payload as text, we need to rewrite the "Content-type" header as well, forcing a "charset=utf-8" to remove encoding mismatches, if any. Another option would be opting for a non-native alternate API which supports as many encodings in output as TextDecoder does in input.
~~We also added a build-time option to minify the browserify output, since this and further upcoming refactorings/bug-fixes unavoidably increase the number of source files, multiplying comments and license boilerplate sections, which in turn may make bundle.js uncomfortably large.~~
This branch refactors out the response processing machinery, except for the script analysis/editing details left to a client callback, into a ResponseProcessor module which:
* The TextEncoder native Web API in its current specification dropped support for any encoding except UTF-8: therefore when using it to edit the response payload as text, we need to rewrite the "Content-type" header as well, forcing a "charset=utf-8" to remove encoding mismatches, if any. Another option would be opting for a non-native alternate API which supports as many encodings in output as TextDecoder does in input.
~~We also added a build-time option to minify the browserify output, since this and further upcoming refactorings/bug-fixes unavoidably increase the number of source files, multiplying comments and license boilerplate sections, which in turn may make bundle.js uncomfortably large.~~