dhowe / ChinaEye

Experience the web as if you were living in China...
Artistic License 2.0
9 stars 3 forks source link

Redact-mode but not redacted #61

Closed dhowe closed 7 years ago

dhowe commented 7 years ago

To recreate: disable or uninstall extension, do google search, re-enable extension.

Icon shows that search is blocked, as does text, however not redacted.

image

cqx931 commented 7 years ago

For this case content-script didn't get the chance to be injected into the current page. Once the user refresh the page it should be fine.

If we want the page to be redacted without manual refreshing in this case, it should Option 1: Renew all tabs on install/enabled?(not sure how to detect this) But this doesn't sound good to me when the user has many tabs open.

Option 2 Ideally it should refresh the page if the page is 1.current page 2.if ChinaEye has never ran "checkPage" on this page(firstInstall/reenabled...) when getBlockingStatus request is made from popup and there is no status for the tabId in localStorage(Not sure whether this is precise enough...)

dhowe commented 7 years ago

Are these the steps when menu is opened?

  1. current-tab domain and search query are sent from popup to addon
  2. check cache for existing status, if exists return it, if not then check-server
  3. send results back to popup for display
  4. send results to tab's content-script for display
dhowe commented 7 years ago

Question: could this happen at other times, beside install or re-enable ?

cqx931 commented 7 years ago
  1. current-tabId and url are sent from popup to extension
  2. check cache for existing status, if exists return it, if not then checkPage(1.check whether it is on white list 2.if on search engine check keyword 3.if not blocked by keyword check server)
  3. send results back to popup for display

Content-script is injected whenever a new page is loaded, this is separated from popup and will also ask extension to checkPage.

The core issue here is redacted style don't get injected into the page. Besides install and re-enable, which is the case when the whole content-script is not injected to the page, it could also be the following scenario: A page which is used to be allowed by the server, got failing result after recheck. In this case, since the page was not redacted before, redacted style was not injected when content-script first loaded. For the later scenario, if rechecking server got a different blocking status compared with the previous one, the page should reload.

dhowe commented 7 years ago

is there a reason not to send a reapplyStyle message to the content-script for these cases (maybe for v1.1)?

cqx931 commented 7 years ago

I see...yes, reapplyStyle message is better. I think it's better to do it for v1.0, as it influence the performance on first-install...

cqx931 commented 7 years ago

https://github.com/dhowe/ChinaEye/pull/63