Skip to content

Commit 1638290

Browse files
committed
updated bright horizon script
1 parent d05b4a8 commit 1638290

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

picture_download/bright_horizons.user.js

+43-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,38 @@
11
// ==UserScript==
22
// @name download bright horizon pictures
33
// @namespace http://tampermonkey.net/
4-
// @version 0.1
4+
// @version 0.3
55
// @description use on your own risk
66
// @author wang19891218
7-
// @match https://mybrightday.brighthorizons.com/m/p/*
8-
// @match https://mybrightday.brighthorizons.com/m/v/*
9-
// @downloadURL https://github.com/wang19891218/tampermonkey-scripts/raw/master/picture_download/bright_horizons.user.js
10-
// @updateURL https://github.com/wang19891218/tampermonkey-scripts/raw/master/picture_download/bright_horizons.user.js
7+
// @match https://productionmbd.brighthorizons.com/m/snapshot/*
8+
// @match https://productionmbd.brighthorizons.com/m/p/*
9+
// @match https://productionmbd.brighthorizons.com/m/v/*
10+
// @match https://productionmbd.brighthorizons.com/m/observation/*
1111
// @icon https://www.google.com/s2/favicons?domain=brighthorizons.com
1212
// @grant none
1313
// ==/UserScript==
1414

15-
(function() {
15+
// TODO
16+
// * Add the date of uuid to file name
17+
18+
function get_time_int(uuid_str) {
19+
var uuid_arr = uuid_str.split( '-' ),
20+
time_str = [
21+
uuid_arr[ 2 ].substring( 1 ),
22+
uuid_arr[ 1 ],
23+
uuid_arr[ 0 ]
24+
].join( '' );
25+
return parseInt( time_str, 16 );
26+
};
27+
28+
function get_date_obj(uuid_str) {
29+
var int_time = get_time_int( uuid_str ) - 122192928000000000,
30+
int_millisec = Math.floor( int_time / 10000 );
31+
return new Date( int_millisec );
32+
};
33+
34+
35+
function saveFigure() {
1636
'use strict';
1737
if (document.title.includes("Link Expired") ) {
1838
var listA = [].slice.call(document.getElementsByTagName("a"))
@@ -22,8 +42,20 @@
2242
} else {
2343
// Get URL
2444
console.log(window.location.href)
25-
var url = window.location.href + "?d=t"
26-
console.log(url)
45+
let endString = "?d=t&thumbnail=true"
46+
if (document.location.href.endsWith(endString)) {
47+
var url = window.location.href.substring(
48+
0, window.location.href.length - endString.length)
49+
}
50+
let uuid = url.substring(url.lastIndexOf("/") + 1)
51+
console.log(uuid)
52+
let date = get_date_obj(uuid)
53+
console.log(date)
54+
console.log(date.getFullYear().toString())
55+
console.log(date.getMonth().toString())
56+
console.log(date.getDate().toString())
57+
url = url + "?d=t"
58+
// console.log(url)
2759
// Get current date var today = new Date();
2860
var today = new Date();
2961
var dd = String(today.getDate()).padStart(2, '0');
@@ -41,4 +73,6 @@
4173
document.body.removeChild(a)
4274
window.close();
4375
}
44-
})();
76+
}
77+
78+
saveFigure()

0 commit comments

Comments
 (0)