HabitRPG / habitica-chrome

Chrome extension for HabitRPG. Uses 3rd party productivity website events to trigger point gain/loss.
https://chrome.google.com/webstore/detail/habitrpg/pidkmpibnnnhneohdgjclfdjpijggmjj?hl=en-US
GNU General Public License v3.0
109 stars 47 forks source link

Add support for Pomodoro-tracker #136

Closed Belphemur closed 8 years ago

Belphemur commented 8 years ago

I've been testing and using this Pomodoro tracker and binding for more or less a month. It works flawlessly.

Tracker: https://pomodoro-tracker.com/

paglias commented 8 years ago

@Belphemur this would be in addition to the current Pomodoro tracker?

I'm not sure we want to support 2 different integrations that solve the same problem, there are any advantages in using this over the current one?

Belphemur commented 8 years ago

First one is the fact it's linked to the time of your computer to register the different task. The user interface is more friendly than Tomatoes. Moreover, it's still a developed project where the dev listens to feedbacks.

You can set the duration for the Pomodoro and breaks to your liking, also the volume of the different sound (alarm and tick sounds).

Instead of having to enter the task at each Pomodoro done, you set a Task list (as asked by the Pomodoro method in fact) where you can directly set how many Pomodoro it will take.

Each task is taggable and can be named. In the provided statistic, the task will be regrouped by tag (category).

And last but not least, you can export and import data in CSV format. Useful if you want to do your data analysis.

Ps: I searched online for the best Pomodoro tool, and trust me, after trying 5-6 differents one, this one stood out, sure there is typos on the page, but the code is robust, and the application works flawlessly.

paglias commented 8 years ago

@Belphemur looks great! I'm in the process of publishing it right now, also I'm awarding your second level badge.

Belphemur commented 8 years ago

@paglias I'm glad you find it useful. Thank you for the second badge!

I'll maybe come with more pull request in the future to add some interactivity in the popup, like being able to interact with the habits or todo.

klen commented 8 years ago

@Belphemur Hello Antoine, I'm a developer of the pomodoro-tracker.com. Thank you for the feedback! Nice to hear it!

I have seen the code of the integration and make the decision to help with.

So I've added event pomodoro_timer_finished to document object. It provides mode argument (pomodoro, short, long). So now you may easy listen jQuery(document).on('pomodoro_timer_finished', function (e, mode) {...}) and dont need to track HTML elements. I you need additional information (events) feel free to ask me.

PS:

sure there is typos on the page

It would be great if you tell me about. English is not my best thing :(

Belphemur commented 8 years ago

@klen thank you for those events; I'll implement them as soon as possible.

For the typo, I sent you an email about it.

Belphemur commented 8 years ago

@klen Could you add in the event, in case it's a Pomodoro, which Pomodoro has been achieved? (like the first (1), second (2), etc.)

Can you also add another one when the Pomodoro is interrupted? Like when pushing the stop button?

klen commented 8 years ago

@Belphemur done 2 events: pomodoro_timer_finished, [mode, num] where mode is one of [pomodoro, long, short] and num — how much pomodoros have been done

and

pomodoro_timer_stopped, when user has stopped a pomodoro

Belphemur commented 8 years ago

@klen thank you very much. I'll implement them tomorrow. That will make the binding perfect!

Belphemur commented 8 years ago

@klen After checking the code again, I would need one last event. It's used to trigger the site-watcher to verify if the user is browsing the right website.

pomodoro_timer_started, [mode] with this last one, the binding will have all the needed features.

Edit: It seems the events are not triggered on the document. My listener never get triggered.

klen commented 8 years ago

Mmm, you can check, open chrome console on pomodoro-tracker and print jQuery(document).on('pomodoro_timer_stopped', function () {console.log('it works!')}) and start/stop pomodoro.

Maybe you should use window.jQuery from pomodoro-tracker instead your own jQuery?

Belphemur commented 8 years ago

You're right, with your test it's working perfectly well, but the problem lies in the way the extension and content_script are loaded:

Although the execution environments of content scripts and the pages that host them are isolated from each other, they share access to the page's DOM.

Could you use the default triggering of event without using jQuery and directly on the Window instead of document as explained here: https://developer.chrome.com/extensions/content_scripts#host-page-communication

Doing something like:

window.postMessage({ type: "pomodoro_timer_finished", mode: "pomodoro", num: 2 }, "*");

From the documentation, I should be able to get those message directly to the content script.

klen commented 8 years ago

Wow, I didn't know about. Have changed to window.postMessage.

Belphemur commented 8 years ago

@klen I confirm with this method it works! We both learned something today :)

Could you also add the started event? When the Pomodoro timer is started and what is started (break/long break/Pomodoro). The same as finished in fact.

With that, I'll be able to make a pull request with all these changes. Thank you greatly for your time!

klen commented 8 years ago

done