Refactored

About: GreasyFork Bullshit Filter

Hi, I just wanted to offer a refactored version of your code. Of course you don't have to use it, but I thought I'd show it to you in case you wanted to use it (or parts of it). It should make maintaining the filter list and CSS easier.

https://gist.github.com/valacar/7b17986b9b0fddb874a4c1e736167162

I think the changes are pretty straightforward, but mainly you'll notice the site object that's created based on which website you're on, and groups together some variables and functions. The CSS code had lot of duplication, so I separated out the common part. Then I removed the greasemonkey setValue and getValue function since it seemed you were already using localStorage and @grant none. Besides that I just converted some things to ES6 like var to const/let and for of loops. Oh, and in your CSS, the "!important" parts are not necessary since you're not overriding the site's style. I think that's about it.

If you decide to use it, make sure to remove the "refactored" part of @name and @version. Also, no need to credit me or anything.

Réponses

  • September 2018 modifié Chrome

    Thanks a lot for your work and also for taking the time to explain in details! I really like it! 👌

    My purpose to make it work just greasyfork, keeping it as close as possible to the initial version, but you made it modern (ES6) and parametric, clean and minimized, way much easier to maintain!

    Then I removed the greasemonkey setValue and getValue function since it seemed you were already using localStorage

    I had kept these from the original version as they were the choices of the author.
    although I'd noticed too that.

    If you decide to use it

    I used your version almost intact,
    and also applied it to the other script versions that I keep (for Citrus GFork -there the !important are needed-, and for OUJS).

    Thanks again! 👍


    Also, no need to credit me or anything.

    No way!
    Adding the following:

    // @author      kuehlschrank, darkred, valacar
    //    Thanks a lot to valacar for the refactoring.
    

    was the least I can do. :smile:


    If you'd ever like to contribute again to any of my scripts,
    feel free to make a pull request :smile: I'd be glad to merge!

Connectez-vous ou Inscrivez-vous pour répondre.