Skip to content

Commit 38c0651

Browse files
authored
Merge pull request #17 from RakSrinaNa/develop
2.2.1 Release
2 parents 45feb1c + ff975bc commit 38c0651

20 files changed

+102
-74
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# Changelog
22

3+
## [2.2.1] - 2019-11-08
4+
5+
- Update Amcharts to 4.7.8.
6+
- Improve player detection.
7+
38
## [2.2.0] - 2019-11-07
49

510
- Update Amcharts to 4.7.7.
611
- When watching a video across several days the time is split between these days instead of all being on the last day (#15).
7-
- Added a button in the settings to export the data directly on Dropbox.
12+
- Added a button in the settings to export the data directly on Dropbox (#10).
813

914
## [2.1.3] - 2019-10-08
1015

Mozilla-libs.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Library used:
2+
3+
jQuery 3.4.1 from https://jquery.com/download/ "Download the compressed, production jQuery 3.4.1"
4+
Amcharts 4.7.7 from https://www.amcharts.com/download/ "Download a standalone JavaScript version"
5+
Bootstrap 4.3.1 from https://getbootstrap.com/docs/4.3/getting-started/download/#compiled-css-and-js
6+
Popper.js 1.15.0 from https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.15.0/umd/popper.js
7+
DropboxSDK 4.0.30 from https://www.npmjs.com/package/dropbox/v/4.0.30

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Bootstrap - [https://getbootstrap.com/](https://getbootstrap.com/)
3737

3838
JQuery - [https://github.com/jquery/jquery](https://github.com/jquery/jquery)
3939

40+
Dropbox SDK - [https://www.dropbox.com/developers/documentation/javascript](https://www.dropbox.com/developers/documentation/javascript)
41+
4042
## Other
4143
Compare versions function from [em92's gist](https://gist.github.com/em92/d58944f21c68b69433cefb6c49e0defd).
4244

includes/js/background.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
const YTT_MS_PER_DAY = 86400 * 1000;
42
const activePlayers = {};
53

@@ -39,7 +37,7 @@ function setupExtension() {
3937

4038
newConfig[YTT_CONFIG_TOTAL_STATS_KEY] = totalStats;
4139

42-
YTTRemoveConfig([YTT_CONFIG_TOTAL_TIME_KEY, YTT_CONFIG_REAL_TIME_KEY], null);
40+
YTTRemoveConfig([YTT_CONFIG_TOTAL_TIME_KEY, YTT_CONFIG_REAL_TIME_KEY]);
4341
}
4442

4543
YTTRemoveConfig(['YTTHanddrawn', 'YTTTheme']);
@@ -93,14 +91,14 @@ function sendRequestsToAPI(requests) {
9391
},
9492
method: 'POST',
9593
async: true,
96-
error: function () {
94+
error: () => {
9795
notify(`Failed to send ${type} time to server`, `VideoID: ${videoId}\nDuration: ${duration.getAsString(true)}\nDate: ${timeStr}`);
9896
console.error('Failed to send request to API', uuid, videoId, duration, date, type);
9997
if (onFail) {
10098
onFail();
10199
}
102100
},
103-
success: function () {
101+
success: () => {
104102
notify(`Sent ${type} time to server`, `VideoID: ${videoId}\nDuration: ${duration.getAsString(true)}\nDate: ${timeStr}`);
105103
console.debug('Sent to API', uuid, videoId, duration, date, type);
106104
if (onSuccess) {
@@ -121,7 +119,7 @@ function sendRequestsToAPI(requests) {
121119
if (trackData && trackData['videoID'] && trackData['duration']) {
122120
sendRequest(uuid, trackData['videoID'], new YTTDuration(trackData['duration']), trackData['date'], trackData['type'], function () {
123121
sendAllRequests(uuid, requests);
124-
}, function () {
122+
}, () => {
125123
YTTConfigAddInArray(YTT_CONFIG_FAILED_SHARE, [trackData]);
126124
sendAllRequests(uuid, requests);
127125
});

includes/js/chart.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ $(function () {
77
YTTGetConfig(null).then(config => {
88
const WEIRD_DATA_THRESHOLD = config[YTT_CONFIG_WEIRD_DATA_THRESHOLD];
99
const weirdData = [];
10-
const data = Object.keys(config).filter(k => k.startsWith('day')).map(k => k.replace('day', '')).sort(function (a, b) {
11-
return YTTCompareConfigDate(b, a);
12-
}).map(function (day) {
10+
const data = Object.keys(config).filter(k => k.startsWith('day')).map(k => k.replace('day', '')).sort((a, b) => YTTCompareConfigDate(b, a)).map(day => {
1311
const conf = new YTTDay(config[`day${day}`]);
1412
const dayData = {
1513
day: day,
@@ -206,7 +204,7 @@ $(function () {
206204
updatePeriodData(periodData);
207205
}
208206

209-
chart.events.on('ready', function () {
207+
chart.events.on('ready', () => {
210208
let oneWeekAgo = new Date();
211209
oneWeekAgo.setHours(0);
212210
oneWeekAgo.setMinutes(0);

includes/js/content.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function injectCode() {
4343
body.append(YTTGetInjectDiv(YTT_DOM_PLAYER_TIME_1, '0'));
4444
body.append(YTTGetInjectDiv(YTT_DOM_PLAYER_TIME_2, '0'));
4545

46-
$(window).on('beforeunload', function () {
46+
$(window).on('beforeunload', () => {
4747
const event = {};
4848
event[YTT_STATE_EVENT_STATE_KEY] = YTT_STATE_EVENT_STATE_KEY_WATCHED;
4949
event[YTT_STATE_EVENT_TIME_KEY] = $(`#${YTT_DOM_PLAYER_TIME_2}`).text();
@@ -77,7 +77,7 @@ function injectCode() {
7777
* @param {function} callback
7878
*/
7979
function observeElement(id, callback) {
80-
const observer = new MutationObserver(function (mutations) {
80+
const observer = new MutationObserver(mutations => {
8181
mutations.forEach(callback);
8282
});
8383
observer.observe(document.getElementById(id), {
@@ -91,7 +91,7 @@ function injectCode() {
9191
YTTLog('Injected player dom');
9292
}
9393

94-
$(function () {
94+
$(() => {
9595
if (window && window.location && window.location.href && window.location.href.startsWith('https://yttracker.mrcraftcod.fr/')) {
9696
$('.extensionsAd').hide();
9797
} else {

includes/js/editHighValues.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
$(function () {
2-
$('#backButton').on('click', function () {
2+
$('#backButton').on('click', () => {
33
document.location.href = 'chart.html';
44
});
55

@@ -21,7 +21,7 @@ $(function () {
2121
$('#days-edit-input').val(obj.conf[kind].days);
2222
}
2323

24-
$('#edit-form').on('submit', function (e) {
24+
$('#edit-form').on('submit', e => {
2525
e.preventDefault();
2626
const newDuration = new YTTDuration(editingKind, 0, parseInt($('#seconds-edit-input').val() || '0', 10), parseInt($('#minutes-edit-input').val() || '0', 10), parseInt($('#hours-edit-input').val() || '0', 10), parseInt($('#days-edit-input').val() || '0', 10));
2727
console.log('New duration parsed', newDuration, editingKind, editingVar.dayStr);
@@ -44,9 +44,7 @@ $(function () {
4444
});
4545
});
4646

47-
Object.keys(config).filter(k => k.startsWith('day')).map(k => k.replace('day', '')).sort(function (a, b) {
48-
return YTTCompareConfigDate(b, a);
49-
}).map(day => {
47+
Object.keys(config).filter(k => k.startsWith('day')).map(k => k.replace('day', '')).sort((a, b) => YTTCompareConfigDate(b, a)).map(day => {
5048
return {
5149
day: YTTGetDateFromDay(day),
5250
dayStr: day,
@@ -64,7 +62,7 @@ $(function () {
6462
if (obj.conf.getOpenedDuration().getAsMilliseconds() > WEIRD_DATA_THRESHOLD) {
6563
let buttonEditOpened = $(`<button type="button" class="btn btn-primary btn-block edit-conf-value" data-toggle="modal" data-target="#modal-time">`)
6664
.text(`Edit opened time of the ${YTTGetDateString(obj.day.getTime())} (${obj.conf.getOpenedDuration().getAsString()})`);
67-
buttonEditOpened.on('click', function (e) {
65+
buttonEditOpened.on('click', e => {
6866
startEdit($(this), obj, YTT_DATA_OPENED);
6967
});
7068
$('<div class="row mt-1">').append(buttonEditOpened).appendTo(editDiv);

includes/js/hooker.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,35 @@
22
* Setup hook onto the YouTube player.
33
*/
44
function YTTHookProcess() {
5-
const RETRY_DELAY = 250;
6-
let hooked = false;
7-
try {
8-
let YTTPlayerTemp;
9-
YTTPlayerTemp = document.getElementById('movie_player');
10-
if (YTTPlayerTemp && hookYTTPlayer)
11-
hooked = hookYTTPlayer(YTTPlayerTemp);
12-
}
13-
catch (ignored) {
14-
}
15-
if (hooked)
16-
YTTUpdateDOM();
17-
else
18-
setTimeout(YTTHookProcess, RETRY_DELAY);
5+
const RETRY_DELAY = 250;
6+
let hooked = false;
7+
try {
8+
console.debug('Trying to hook to player');
9+
let YTTPlayerTemp;
10+
YTTPlayerTemp = document.getElementById('movie_player');
11+
if (YTTPlayerTemp && hookYTTPlayer) {
12+
hooked = hookYTTPlayer(YTTPlayerTemp);
13+
}
14+
} catch (ignored) {
15+
}
16+
if (hooked) {
17+
YTTUpdateDOM();
18+
} else {
19+
setTimeout(YTTHookProcess, RETRY_DELAY);
20+
}
1921
}
2022

2123
/**
2224
* Called when the hook is successfull and start a scheduled task to update current player time continuously.
2325
*/
2426
function YTTUpdateDOM() {
25-
setInterval(function () {
26-
const YTTTempPlayer = YTTGetPlayer();
27-
if (YTTTempPlayer && YTTTempPlayer.getCurrentTime && YTTTempPlayer.getCurrentTime()) {
28-
document.getElementById(YTT_DOM_PLAYER_TIME_2).innerHTML = document.getElementById(YTT_DOM_PLAYER_TIME_1).innerHTML;
29-
document.getElementById(YTT_DOM_PLAYER_TIME_1).innerHTML = YTTTempPlayer.getCurrentTime();
30-
}
31-
}, 75);
27+
setInterval(() => {
28+
const YTTTempPlayer = YTTGetPlayer();
29+
if (YTTTempPlayer && YTTTempPlayer.getCurrentTime && YTTTempPlayer.getCurrentTime()) {
30+
document.getElementById(YTT_DOM_PLAYER_TIME_2).innerHTML = document.getElementById(YTT_DOM_PLAYER_TIME_1).innerHTML;
31+
document.getElementById(YTT_DOM_PLAYER_TIME_1).innerHTML = YTTTempPlayer.getCurrentTime();
32+
}
33+
}, 75);
3234
}
3335

3436
YTTHookProcess();

includes/js/hookerUtils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
let YTTHooked = false;
21
let YTTPlayer;
32

43
/**
54
* Update the player state in the DOM.
65
* @param {number} playerState The event of the player (player status).
76
*/
87
function changeDOMTime(playerState) {
8+
console.log("ps", playerState);
99
if (playerState === 1) {
1010
document.getElementById(YTT_DOM_PLAYER_STATE).innerHTML = YTT_STATE_EVENT_STATE_KEY_PLAYING + YTT_DOM_SPLITTER + YTTGetPlayer().getCurrentTime();
1111
} else if (playerState === 2 || playerState === 0 || playerState === -5 || playerState === 3) {
@@ -26,6 +26,7 @@ function changeDOMInfos() {
2626
* Called when the video changes.
2727
*/
2828
function changeVideo() {
29+
console.log("v");
2930
if (YTTGetPlayer().getVideoData && YTTGetPlayer().getVideoData()['video_id'] !== (document.getElementById(YTT_DOM_PLAYER_INFOS).innerHTML.split(YTT_DOM_SPLITTER)[0] || '') && YTTGetPlayer().getCurrentTime && YTTGetPlayer().getDuration) {
3031
changeDOMTime(-5);
3132
changeDOMInfos();
@@ -46,11 +47,10 @@ function YTTGetPlayer() {
4647
* @returns {boolean} True if successfull, false otherwise.
4748
*/
4849
function hookYTTPlayer(player) {
49-
if (YTTHooked || typeof player !== 'object' || !(player.getCurrentTime || player.getVideoData || player.getDuration || player.getPlayerState)) {
50+
if (typeof player !== 'object' || !(player.getCurrentTime || player.getVideoData || player.getDuration || player.getPlayerState)) {
5051
return false;
5152
}
5253
console.log('Player hooked');
53-
YTTHooked = true;
5454
YTTPlayer = player;
5555
document.getElementById(YTT_DOM_PLAYER_TIME_1).innerHTML = YTTPlayer.getCurrentTime();
5656
document.getElementById(YTT_DOM_PLAYER_TIME_2).innerHTML = YTTPlayer.getCurrentTime();

includes/js/lib/amcharts/CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
55
Please note, that this project, while following numbering syntax, it DOES NOT
66
adhere to [Semantic Versioning](http://semver.org/spec/v2.0.0.html) rules.
77

8+
## [4.7.8] - 2019-11-05
9+
10+
### Added
11+
- `itemIndex` added to `AxisDataItem`. Shows current index of data item on the axis.
12+
13+
### Changed
14+
- `extremeschanged` is now dispatched by `DateAxis` when the `min`/`max` are animating.
15+
16+
### Fixed
17+
- Setting `maskBullets` on an `XYChart` will toggle on or off bullet masking dynamically.
18+
- In some particular cases some Sankey nodes were drawn out of bounds.
19+
- `behaviorcanceled` event of `ChartCursor` was not being fired.
20+
- Regression plugin was failing when added to Series object that was not yet attached to a Chart.
21+
- JSON config was failing where Label's `text` or `html` properties were being set to percent value.
22+
- Toggling of `DateAxis.skipEmptyPeriods` was not working after the chart was already inited.
23+
24+
825
## [4.7.7] - 2019-11-02
926

1027
### Added
@@ -1226,7 +1243,7 @@ adhere to [Semantic Versioning](http://semver.org/spec/v2.0.0.html) rules.
12261243
## [4.0.16] - 2019-01-05
12271244

12281245
### Added
1229-
- New locales: Norwegian Bokmål (np_NO), Danish (da_DK).
1246+
- New locales: Norwegian Bokm? (np_NO), Danish (da_DK).
12301247

12311248
### Changed
12321249
- Renamed Swedish locale to `sv_SE`.

0 commit comments

Comments
 (0)