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

pageText (article detection and content capture) not working on Chrome #280

Open
Tracked by #48
rhelmer opened this issue Jun 23, 2022 · 3 comments
Open
Tracked by #48
Assignees

Comments

@rhelmer
Copy link
Contributor

rhelmer commented Jun 23, 2022

pageText tries to pass filters to browser.tabs.onUpdated.addListener which is Firefox-only, filtering needs to be done in the callback instead.

@rhelmer
Copy link
Contributor Author

rhelmer commented Jul 28, 2022

OK, so Firefox has an isArticle filter that this is using specifically:

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/onUpdated#isarticle

isArticle Optional
boolean. True if the tab is an article and is therefore eligible for display in Reader Mode.

I think we'll need to instead handle this in the callback, and use the Readability library (which is a standalone version of the code that powers Firefox's reader mode, and we already ship it in beyond-the-paywall. There's an npm package)

@rhelmer
Copy link
Contributor Author

rhelmer commented Jul 28, 2022

OK, so Firefox has an isArticle filter that this is using specifically:

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/onUpdated#isarticle

isArticle Optional
boolean. True if the tab is an article and is therefore eligible for display in Reader Mode.

I think we'll need to instead handle this in the callback, and use the Readability library (which is a standalone version of the code that powers Firefox's reader mode, and we already ship it in beyond-the-paywall. There's an npm package)

Specifically the isProbablyReaderable() function.

@rhelmer rhelmer changed the title tabs.onUpdated.addListener does not accept filters on Chrome pageText (article detection and content capture) not working on Chrome Jul 29, 2022
@rhelmer rhelmer self-assigned this Jul 29, 2022
@rhelmer
Copy link
Contributor Author

rhelmer commented Jul 30, 2022

Small correction - we can't directly get the page contents from the listener (which is in the background script/worker), so instead I put the probablyIsReaderable() call in the content script, which does have direct access to the DOM of the web page. It does an early-return and does not send a message if this call is false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant