-
Notifications
You must be signed in to change notification settings - Fork 0
/
devtools.js
176 lines (163 loc) · 6.45 KB
/
devtools.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
var app = angular.module('devtools', []);
app.controller('devtools-controller', ['$scope', ($scope) => {
$scope.fontSmoothingItems = ['none', 'subpixel-antialiased', 'antialiased', 'unset', 'auto', 'initial'];
$scope.loadDevtools = () => {
$scope.devtools = chrome.devtools.panels;
$scope.restoreDefaultValues();
chrome.storage.sync.get(['fontFamily', 'fontSize', 'fontWeight', 'textWidthSize', 'fontSmoothing', 'codeLineHeight',
'plaformFontFamily', 'plaformFontSize', 'plaformFontWeight'], (items) => {
if (Object.keys(items).length > 0) {
$scope.devtools.applyStyleSheet($scope.setTemplate(items));
Object.keys(items).forEach((key) => {
$scope[key] = items[key];
});
}
$scope.devtools.create('Devtools Styler', 'assets/img/pantone.png', 'index.html', () => {
setTimeout(() => {
$scope.$apply();
});
});
});
}
$scope.saveSettings = (event) => {
if (event.ctrlKey || event.metaKey) {
switch (String.fromCharCode(event.which).toLowerCase()) {
case 's':
event.preventDefault();
$scope.setStorage();
break;
}
}
}
$scope.restoreDefaultValues = (clearStorage) => {
$scope.fontFamily = '';
$scope.fontSize = 12;
$scope.fontWeight = 400;
$scope.textWidthSize = 0;
$scope.fontSmoothing = 'none';
$scope.codeLineHeight = 15;
$scope.plaformFontFamily = '';
$scope.plaformFontSize = 12;
$scope.plaformFontWeight = 400;
if (clearStorage) {
chrome.storage.sync.clear();
$scope.showAlert();
}
}
$scope.setStorage = () => {
chrome.storage.sync.set({
fontFamily: $scope.fontFamily,
fontSize: $scope.fontSize,
fontWeight: $scope.fontWeight,
textWidthSize: $scope.textWidthSize,
fontSmoothing: $scope.fontSmoothing,
codeLineHeight: $scope.codeLineHeight,
plaformFontFamily: $scope.plaformFontFamily,
plaformFontSize: $scope.plaformFontSize,
plaformFontWeight: $scope.plaformFontWeight
}, () => {
$scope.showAlert();
});
}
$scope.showAlert = () => {
$('#save-message').hide();
clearTimeout($scope.timeout);
$('#save-message').slideDown(300);
$scope.timeout = setTimeout(() => {
$('#save-message').slideUp(300);
}, 3000);
}
$scope.setFontSmoothing = (item) => {
$scope.fontSmoothing = item;
}
$scope.confirmDialog = () => {
$('#reset-modal').modal({
backdrop: 'static',
keyboard: false
});
$('.btn-yes').click(() => {
$scope.restoreDefaultValues(true);
$('#reset-modal').modal('hide');
})
}
$scope.setTemplate = (items) => {
var styleSheet =
`:host-context(.platform-mac) .monospace,
:host-context(.platform-mac) .source-code,
.platform-mac .monospace,
.platform-mac .source-code,
:host-context(.platform-windows) .monospace,
:host-context(.platform-windows) .source-code,
.platform-windows .monospace,
.platform-windows .source-code,
:host-context(.platform-linux) .monospace,
:host-context(.platform-linux) .source-code,
.platform-linux .monospace,
.platform-linux .source-code,
.CodeMirror pre,
#console-messages .source-code,
.stack-preview-container {
font-family: ${items.fontFamily} !important;
font-size: ${items.fontSize}px !important;
-webkit-text-stroke-width: ${items.textWidthSize}px;
-webkit-font-smoothing: ${items.fontSmoothing};
font-weight: ${items.fontWeight} !important;
}
.platform-linux, .platform-mac, .platform-windows{
font-family: ${items.plaformFontFamily} !important;
font-size: ${items.plaformFontSize}px !important;
font-weight: ${items.plaformFontWeight} !important;
}
.CodeMirror-lines {
line-height: ${items.codeLineHeight}px !important;
}
.cm-breakpoint .CodeMirror-gutter-wrapper .CodeMirror-linenumber {
height: ${items.codeLineHeight}px !important;
line-height: ${items.codeLineHeight}px !important;
display: flex;
justify-content: center;
flex-direction: column;
text-align: right;
}
.CodeMirror-gutter-elt{
top : 0px !important;
}
.tree-outline-disclosure .tree-outline > li,
.tree-outline-disclosure.tree-outline-disclosure-hide-overflow .tree-outline li,
.elements-disclosure .elements-tree-outline.source-code li,
.tree-outline-disclosure .tree-outline.hide-selection-when-blurred.source-code.object-properties-section li {
line-height: ${items.codeLineHeight}px !important;
min-height: ${items.codeLineHeight}px !important;
font-size: ${items.fontSize}px !important;
-webkit-text-stroke-width: ${items.textWidthSize}px;
-webkit-font-smoothing: ${items.fontSmoothing}
}
.elements-disclosure .elements-tree-outline.source-code li.parent::before{
-webkit-mask-position-y: 0.14em !important;
cursor: pointer;
}
.elements-disclosure .elements-tree-outline.source-code li.parent.expanded::before{
-webkit-mask-position-y: 0.05em !important;
}
.tree-outline-disclosure .tree-outline.tree-outline-dense > .parent,
.tree-outline-disclosure .tree-outline.tree-outline-dense .header-name {
-webkit-text-stroke-width: 0.1px;
font-weight: normal;
}
.tree-outline-disclosure .tree-outline.tree-outline-dense .header-name {
color: #bb0000;
font-size: ${items.fontSize}px !important;
}
.tree-outline-disclosure .tree-outline.tree-outline-dense > .parent{
color: #252525;
}
.tree-outline-disclosure .tree-outline.tree-outline-dense li.expanded .header-toggle {
margin-left: 15px;
}
.tree-outline-disclosure .tree-outline.hide-selection-when-blurred.source-code.object-properties-section .name-and-value {
line-height: inherit;
}`;
return styleSheet;
}
document.addEventListener('DOMContentLoaded', $scope.loadDevtools());
}]);