Giter Site home page Giter Site logo

Blocking home page only about block-site HOT 5 CLOSED

penge avatar penge commented on July 29, 2024
Blocking home page only

from block-site.

Comments (5)

bard avatar bard commented on July 29, 2024

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?

from block-site.

penge avatar penge commented on July 29, 2024

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.

from block-site.

bard avatar bard commented on July 29, 2024

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.)

from block-site.

penge avatar penge commented on July 29, 2024

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 ?

from block-site.

bard avatar bard commented on July 29, 2024

No, I used pnpm run build.

from block-site.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.