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

Adds basic static black- and whitelist checking #60

Merged
merged 2 commits into from
Apr 18, 2017

Conversation

glennsl
Copy link
Collaborator

@glennsl glennsl commented Apr 17, 2017

Fixes #17
Fixes #40
Kind of fixes #46
Workaround for #49

Constitutes phase 1 of the masterplan for #48

@rickyvetter
Copy link
Collaborator

How complex are you imagining this logic will become? Would it make more sense to have a separate content script which registers with the whitelisted pages? https://developer.chrome.com/extensions/content_scripts#registration

@glennsl
Copy link
Collaborator Author

glennsl commented Apr 17, 2017

I don't expect the hardcoded lists to be used extensively, especially not the whitelist. This is intended more as a workaround until the detection logic can be properly fixed. But i'd like to add UI to allow users to add these workarounds themselves, and to eventually be able to report them back to us for fixing.

As for the pattern matching itself, I don't expect anything crazier than wildcard matching.

Copy link
Collaborator

@rickyvetter rickyvetter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. All for giving more control :) Left a couple comments but this looks good to me. I think it needs a rebase to be merged.

Js.log @@ "mightBeOcamlDoc: " ^ (string_of_bool @@ mightBeOcamlDoc ());
Js.log @@ "isBlackListed: " ^ (string_of_bool @@ isBlacklisted ());
Js.log @@ "shouldConvert: " ^ (string_of_bool (isWhitelisted () || (mightBeOcamlDoc () && not (isBlacklisted ()))));
isWhitelisted () || (mightBeOcamlDoc () && not (isBlacklisted ()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make sure these (especially mightBeOcamlDoc) only get called once?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once per what? It could of course be cached in some storage area, but the chrome API is async and would make the logic messier (though if we just cache shouldConvert it wouldn't be as bad), and dom/localStorage APIs aren't isolated.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once per page load - right now mightBeOcamlDoc gets called three times, right? No need to cache across visits.

Copy link
Collaborator Author

@glennsl glennsl Apr 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just twice I think? One for ContentLoader to check if Content should be loaded, and then in Content itself. The simplest way I guess would be to just add a flag to window. Would that be ok you think?

Edit: Oh, it's actually four times with the logging, that could be improved of course :)

Js.log @@ "isWhitelisted: " ^ (string_of_bool @@ isWhitelisted ());
Js.log @@ "mightBeOcamlDoc: " ^ (string_of_bool @@ mightBeOcamlDoc ());
Js.log @@ "isBlackListed: " ^ (string_of_bool @@ isBlacklisted ());
Js.log @@ "shouldConvert: " ^ (string_of_bool (isWhitelisted () || (mightBeOcamlDoc () && not (isBlacklisted ()))));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really like these logs for dev mode and am happy to leave them in - can you verify that the console logs get stripped in production? I don't want to force people to see this on every page load.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can verify that it does not get stripped. I could hide them behind a debug flag perhaps, for easier debugging in the wild.

@glennsl
Copy link
Collaborator Author

glennsl commented Apr 18, 2017

Ok, I've rebased, commented out the logging and "memoized" the shouldConvert call.

@rickyvetter rickyvetter merged commit 87a0764 into reasonml:master Apr 18, 2017
@glennsl glennsl deleted the black-white-list branch April 18, 2017 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants