Giter Site home page Giter Site logo

Comments (20)

penge avatar penge commented on July 29, 2024 1

We don't need to reset anything 😉

We can just add a new dropdown to Options, where you would pick the era (filter, a view) for the displayed count: All time, This month, This week, Today.

How that sounds? If you agree, feel free to create a new issue.

from block-site.

penge avatar penge commented on July 29, 2024 1

Every blocking is always added to the end. The order is guaranteed.

from block-site.

olfek avatar olfek commented on July 29, 2024 1

@penge looks good to me 👍

from block-site.

penge avatar penge commented on July 29, 2024

Hi @olfek

Counter is reset for a specific rule (let's say youtube.com) when you remove the rule from the blocked list AND then at any time after visit any website (let it be blocked or allowed). The reason for this implementation is that any changes in Options, including changes in blocked list, are saved automatically, and so counter shouldn't be reset immediately as you type the rules, otherwise even a slight change like removing a letter from youtube.com and then adding it back, would cause a reset of its counter.

But to be honest, I was a bit hesitant to add the Counter feature as it introduces a bit of gamification and replaces one addiction (of visiting a website) with another (how many blocked I have today?). I think Counter is not an essential information and doesn't change the fact I tried to access something I shouldn't. Doesn't matter if it was 10x or 100x. Maybe better if I don't know this information. Shall we remove the feature?

from block-site.

olfek avatar olfek commented on July 29, 2024

I would suggest adding a setting to enable/disable the counter rather than removing it completely. Someone might find it to be useful.

If an enable/disable setting is added, I'd recommend having it enabled by default so new users can see the extension in all its glory.

from block-site.

olfek avatar olfek commented on July 29, 2024

Counter is reset for a specific rule (let's say youtube.com) when you remove the rule from the blocked list AND then at any time after visit any website (let it be blocked or allowed). The reason for this implementation is that any changes in Options, including changes in blocked list, are saved automatically, and so counter shouldn't be reset immediately as you type the rules, otherwise even a slight change like removing a letter from youtube.com and then adding it back, would cause a reset of its counter.

Yep this makes a lot of sense honestly, a counter since the rule was added. Besides, the counter would be even more useless if it reset on every new session, as it would be hiding our level of procrastination and unproductivity 😁

I could start a new session several times in one day so the counter wouldn't be very useful then.

from block-site.

olfek avatar olfek commented on July 29, 2024

But, consider this example.

Suppose its been 2 months since I added a block rule.

The first month, I was visiting the blocked site a lot. Then the second month I wasn't visiting it very much.

It would be nice for the counter to show this improvement in a time range of my choice.

from block-site.

penge avatar penge commented on July 29, 2024

...would be hiding our level of procrastination and unproductivity 😁

Exactly 😄

It would be nice for the counter to show this improvement in a time range of my choice.

We already save counter information as timestamps, so it's ready to show chart over time 😅

Maybe we could even add a highscore 🤣

If an enable/disable setting is added, I'd recommend having it enabled by default so new users can see the extension in all its glory.

This is quite easy to add. I was thinking about it. Probably best way to satisfy both parties?

from block-site.

olfek avatar olfek commented on July 29, 2024

This is quite easy to add. I was thinking about it. Probably best way to satisfy both parties?

Sounds good but the enable/disable setting for the counter would be a new issue.

This issue is about when/if and under what circumstances the counter should be reset.

We already save counter information as timestamps, so it's ready to show chart over time 😅

Maybe we could even add a highscore 🤣

lol, to begin with, I think we should keep it simple. For me personally, I would want the counter to reset daily, but someone else might want the counter to reset weekly or monthly or never.

from block-site.

penge avatar penge commented on July 29, 2024

Sounds good but the enable/disable setting for the counter would be a new issue.

Agreed.

lol, to begin with, I think we should keep it simple.

I think the same. I actually think no counter is needed at all. It doesn't bring me value to know my blocked stats. It's not a game.

from block-site.

olfek avatar olfek commented on July 29, 2024

For me it has actually been useful, I can sometimes waste a lot of time on YouTube, the other day I involuntarily visited YouTube and saw the blocked screen with a block count of 30+, it made me re-evaluate my life choices haha 😅

Seeing the number so high reaffirmed my commitment to avoiding YouTube.

The counter makes the user feel guilty, makes them realise they have a problem, this is the counters purpose. Therefore this counter feature makes this extension more effective at combating procrastination, unproductivity and website addictions (YouTube in my case 😅)

from block-site.

penge avatar penge commented on July 29, 2024

Tell me about it 😄 I don't want to see my YouTube counter because that number is just horrible 😄

Soooo. I think we can agree how resetting of counter works is as we need it to be. And can create a new issue to add option to enable show counter, by default shown or not shown?

from block-site.

olfek avatar olfek commented on July 29, 2024

create a new issue to add option to enable show counter, by default shown or not shown?

by default - shown (allow new users to taste all the features)

and yep, create a new issue 👍

I think we can agree how resetting of counter works is as we need it to be.

Not for me unfortunately, I would like a daily reset.

from block-site.

olfek avatar olfek commented on July 29, 2024

Yep that sounds perfect. Lets just use this issue.

from block-site.

olfek avatar olfek commented on July 29, 2024

What would the performance implications be though, if I've been using the extension for 365 days, and I only want the count for today, the code will need to process all blocks that have occurred in the last 365 days to find the block count for today.

from block-site.

olfek avatar olfek commented on July 29, 2024

pseudocode

FOR EACH block IN blockHistory
    IF block.date == today
        blockCount++

would it look something like this?

from block-site.

olfek avatar olfek commented on July 29, 2024

This has the potential to become slower over time if implemented poorly.

from block-site.

penge avatar penge commented on July 29, 2024

What would the performance implications be though, if I've been using the extension for 365 days, and I only want the count for today, the code will need to process all blocks that have occurred in the last 365 days to find the block count for today.

If you would let's say open youtube.com which is blocked, 1 000 000 times over the past 365 days, it would take, to get that information for today, even in an unoptimized way of going over every record, roughly 35 milliseconds. In other words, 1/30 of a second. Woudn't notice a slowdown.

It could be optimized in many ways, for sure. Not saying it is needed, but for example, you don't have to go over everything to find records for Today. You could start at the end and go backwards until you find something else as Today (which would be Yesterday). With this simple optimization, you'd go over only 1/365 (just an example, only valid when you'd have same counts for every day) of all records only and make it thus as fast as 0,1 millisecond. In other words, 1/10000 of a second.

I wound't worry about the performance really. But glad you asked. If curious, you can try this by yourself.

/**
 * Repeats 10-times:
 * Creates an array of "length" with random numbers in range <0, 1)
 * and filters numbers down to numbers that are >0.5.
 * 
 * And prints:
 * - each run duration in ms
 * - average run duration in ms
*/
const test = (length) => {
  const durations = [];
  for (let r = 1; r <= 10; r++) {
    const arr = Array(length).fill().map(() => Math.random());
    const startTime = performance.now();
    const filtered = arr.filter((item) => item > 0.5);
    const endTime = performance.now();
    const duration = endTime - startTime;
    durations.push(duration);
    console.log(`run ${r} duration: ${duration} ms`);
  }
  const averageDuration = durations.reduce((p, c) => p + c, 0) / durations.length;
  console.log(`average run duration: ${averageDuration} ms`);
};


test(1_000_000); // try a different length

from block-site.

olfek avatar olfek commented on July 29, 2024

You could start at the end and go backwards until you find something else as Today (which would be Yesterday).

This is assuming that the counter data retrieved from storage is in the correct order, is that the case?

Is the correct order guaranteed?

from block-site.

penge avatar penge commented on July 29, 2024

@olfek

This feature is now implemented. Here's a preview:

count-period.mov

When you change option to "Show Blocked info page", it would show additional and related options in that area, to show how many times blocked [Yes/No], and blocked period [All Time, This Month, This Week, Today].

Blocked info page message would then depend on the selected period:

youtube.com was blocked 42x.

youtube.com was blocked 38x this month.

youtube.com was blocked 12x this week.

youtube.com was blocked 5x today.

As you can see, any other than "All Time" period is included in the message.

Other changes:

  • I have replaced checkboxes with more descriptive Yes/No and gave options the same work & feel - just dropdowns.
  • All changes saved automatically as before. And now, all changes also synced across other Options pages (not related to sync storage), in case Options are open multiple times (same window, other windows), any changes in options will be applied elsewhere.

What do you think?

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.