Open Procyon-b opened 4 years ago
@Procyon-b As always, thanks very much, and my apologies for the delay in reviewing! I added a PR (#31) for dyn-sites and am trying it out. I would like to look at that first, then move on to dyn-whitelist.
I have an update and two comments:
background.js:toAr()
, it's not immediately obvious to me what RE
and RE2
are doing. For the sake of maintainability, I would like clearer names before merging.Please let me know your thoughts, either here or on the PR. Thanks!
@cxw42 No need to apologize. ;)
querySelectorAll()
, in the userscript. But it should bail quickly when fed with invalid data.Let me explain why I ended with a messy code for handling the dynamic site list.
When I first tried the logic of MutationObserver I had the list hardcoded in the background page. And the idea was to keep it that way for the end user. Then the reasoning came that an outdated filter could potentially overload the pages of a website: if the observer attach itself to the root (or close to) of the document, the function handling the mutation will get called for all modifications of the page. Even if this function has a small footprint, who knows what can go wrong? And the extension would stay that way until the next update. So I made a really simple option page that could handle syntax parsing. Somehow I had to show the user what the parsed result looks like: each line is parsed and the original text is rewritten from the parsed result. Then it got messy when I added comments, and duplicate hosts. Quickly coded but messy result. ;) I will scrap that, and rewrite it in a more simple way.
All this is also the reason why the userscript is the file where my modifications are cleaner and more straightforward (I think).
The revised code is now available. I have created a new branch dyn-final to replace the previous "dyn-sites". And dyn-whitelist has been recreated with the new version.
The source code is now smaller and cleaner.
@gregsadetsky @cxw42
I have created 2 more branches in my fork.
The first one, dyn-final
dyn-sites, implements the handling of "dynamic sites" with a mutation observer. I call dynamic sites, sites that create their form elements dynamically. These forms can't be fixed by the userscript if it doesn't watch for modifications of the DOM tree. Since this is hostname specific, and user defined, a background page and options page have been addedA second branch, dyn-whitelist, adds support for whitelisting a domain (only for a duration of 90 seconds). Apart from an new popup.html page, the background and userscript are only very lightly modified to handle this.
Examples of dynamic site: