1
1
// ==UserScript==
2
2
// @name download bright horizon pictures
3
3
// @namespace http://tampermonkey.net/
4
- // @version 0.1
4
+ // @version 0.3
5
5
// @description use on your own risk
6
6
// @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/*
11
11
// @icon https://www.google.com/s2/favicons?domain=brighthorizons.com
12
12
// @grant none
13
13
// ==/UserScript==
14
14
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 ( ) {
16
36
'use strict' ;
17
37
if ( document . title . includes ( "Link Expired" ) ) {
18
38
var listA = [ ] . slice . call ( document . getElementsByTagName ( "a" ) )
22
42
} else {
23
43
// Get URL
24
44
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)
27
59
// Get current date var today = new Date();
28
60
var today = new Date ( ) ;
29
61
var dd = String ( today . getDate ( ) ) . padStart ( 2 , '0' ) ;
41
73
document . body . removeChild ( a )
42
74
window . close ( ) ;
43
75
}
44
- } ) ( ) ;
76
+ }
77
+
78
+ saveFigure ( )
0 commit comments