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

Blocking home page only #52

Closed
bard opened this issue Jun 18, 2023 · 5 comments · Fixed by #53
Closed

Blocking home page only #52

bard opened this issue Jun 18, 2023 · 5 comments · Fixed by #53
Milestone

Comments

@bard
Copy link

bard commented Jun 18, 2023

Thanks for this extension!

This may be a feature request or a just a question, not sure.

I'd like to block a home page but allow everything else or, at least, specific paths. I tried the following but it didn't work:

youtube.com
!youtube.com/watch
!youtube.com/results

Is that currently possible?

EDIT: I was mistaken, it appears to work just fine. I think I assumed that rules are saved on textarea blur but they seem to be saved on window close. Either way, apologies for the noise and thanks again for sharing your work!

@bard bard closed this as completed Jun 18, 2023
@bard
Copy link
Author

bard commented Jun 18, 2023

So, it's a little more complex and the reason has nothing to do with my edit above:

  1. If you visit the home page from a video page by left-clicking on the top-left logo, the page is not blocked.
  2. If you visit the home page from a video page by middle-clicking on the top-left logo, the page is blocked.
  3. If you visit the home page from a new tab page by entering youtube.com in the address bar, the page is blocked.

Perhaps in case 1) the History API is used instead of a full page reload and that is not intercepted?

@penge
Copy link
Owner

penge commented Jun 19, 2023

Hi @bard!

EDIT: I was mistaken, it appears to work just fine. I think I assumed that rules are saved on textarea blur but they seem to be saved on window close. Either way, apologies for the noise and thanks again for sharing your work!

Just for clarification, textarea is saved on every edit and as you type.

Perhaps in case 1) the History API is used instead of a full page reload and that is not intercepted?

It is exactly as you say. History API / navigation isn't blocked at the moment. I took my time to solve this right away / thus later reply. At first I thought I'd just use "history" API to solve this, but as it's global, and doesn't have knowledge on which tab this navigation is happening, btw more about it at:
https://stackoverflow.com/questions/12865236/chrome-extension-history-api
https://stackoverflow.com/questions/51809258/get-tab-based-history-of-urls-in-chrome-extension-api
I decided to add "tabs" permission which works nicely to solve this.

Please, see the merge request (#53) to try this out. I have followed youtube example you provided to test it out, and it works as expected now.
As this change will be having a new "tabs" permission added, I shall release it as a new major version, 6.0 to be expected.

@penge penge added this to the 6.0 milestone Jun 19, 2023
@bard
Copy link
Author

bard commented Jun 19, 2023

Brilliant, thank you!

I installed the block-history-navigation and it appears to work as intended.

(Side note: I had to add "lib": ["dom", "es2021"] to tsconfig.json to get it to build.)

@penge
Copy link
Owner

penge commented Jun 19, 2023

Glad to hear!

Regarding that build, have you used:

$ npm run build

as at https://github.com/penge/block-site/actions/runs/5310575537/jobs/9612728265?pr=53 ?

@bard
Copy link
Author

bard commented Jun 19, 2023

No, I used pnpm run build.

@penge penge closed this as completed in #53 Jun 25, 2023
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

Successfully merging a pull request may close this issue.

2 participants