forked from ducksper/lichess_enhancement
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
85 lines (68 loc) · 2.34 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var styleConsoleLog = [
"background-image: url(" + chrome.runtime.getURL('ressources/logo/lichess_chess_logo.png') + ")",
"width: 300px",
'height: 300px',
'background-size: cover',
'line-height: 50px'
]
/*
//LOGO
var lichess_chess_logo_url = chrome.runtime.getURL('ressources/logo/chesscom_logo_better.png')
site_title = document.querySelector('.site-title')//.remove()
document.querySelector('.site-title a').remove()
site_title_nav = document.querySelector('.site-title-nav')
var img_url = document.createElement("img");
var a_url= document.createElement("a");
img_url.src = lichess_chess_logo_url
img_url.width = 170
a_url.href = '/'
site_title.appendChild(a_url)
a_url.appendChild(img_url)
*/
//FONT
document.querySelector('html').style.fontfamily = '-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif'
//GET PIECES FROM STORAGE
chrome.storage.sync.get('pieces', function(data) {
if (data['pieces'] != 'none_pieces') {
Pieces.chooseStyleAndApply(data['pieces'])
}
})
//GET BOARD FROM STORAGE
chrome.storage.sync.get('board', function(data) {
if (data['board'] != 'none_board') {
Boards.chooseStyleAndApply(data['board'])
}
})
//METTRE A JOUR LES PIECES SI ACTION UTILISATEUR DANS HTML EXTENSION
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
chrome.storage.sync.get('pieces', function(data) {
if (data['pieces'] == 'none_pieces') {
Pieces.unbindPieces()
Pieces.greatReset()
} else {
Pieces.chooseStyleAndApply(data['pieces'])
}
})
var board_select = document.getElementById('board_select')
chrome.storage.sync.get('board', function(data) {
if (data['board'] == 'none_board') {
Boards.greatReset()
} else {
Boards.chooseStyleAndApply(data['board'])
}
})
})
/*function ghostActivateState() {
chrome.storage.sync.get('desactivateGhostsCustomStyle', function(data) {
if (!data['desactivateGhostsCustomStyle']) {
return false
} else return true
})
}*/
document.addEventListener('mousedown', function() {
chrome.storage.sync.get('pieces', function(data) {
if (data['pieces'] != 'none_pieces') {
Pieces.chooseStyleAndApply(data['pieces'])
}
})
}, false)