Skip to content

Commit 8274764

Browse files
committed
v2.1.0
1 parent 7fdca5f commit 8274764

10 files changed

Lines changed: 4317 additions & 179 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<a href="https://github.com/victor-savinov/dark-mode"><img src="https://github.com/victor-savinov/icons/blob/master/dark-mode/raised-128.png"></a>
2+
<a href="https://github.com/victor-savinov/dark-mode"><img src="https://github.com/victor-savinov/graphics/blob/master/icons/dark-mode/raised-128.png"></a>
33
</p>
44

55
<h3 align="center">Night Mode</h3>

_locales/ru/messages.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
"message": "Внешний вид"
1010
},
1111
"areYouSureYouWantToDeleteTheSelectedWebsiteSettings": {
12-
"message": "Are you sure you want to delete the selected website settings?"
12+
"message": "Вы уверены, что хотите удалить выбранные настройки веб-сайта?"
1313
},
1414
"areYouSureYouWantToExportTheData": {
15-
"message": "Are you sure you want to export the data?"
15+
"message": "Вы действительно хотите экспортировать данные?"
1616
},
1717
"areYouSureYouWantToImportTheData": {
18-
"message": "Are you sure you want to import the data?"
18+
"message": "Вы действительно хотите испортировать данные?"
1919
},
2020
"audioFormats": {
2121
"message": "Форматы аудио"
@@ -36,7 +36,7 @@
3636
"message": "Отмена"
3737
},
3838
"colorTemperature": {
39-
"message": "Color temperature"
39+
"message": "Температура"
4040
},
4141
"contrast": {
4242
"message": "Контраст"
@@ -54,7 +54,7 @@
5454
"message": "Отключено"
5555
},
5656
"dynamicTheme": {
57-
"message": "Dynamic theme"
57+
"message": "Динамическая тема"
5858
},
5959
"excludeThisWebsite": {
6060
"message": "Исключить веб-сайт"
@@ -159,13 +159,13 @@
159159
"message": "Настройки"
160160
},
161161
"somethingWentWrongTryReloadingThePage": {
162-
"message": "Something went wrong. Try reloading the page."
162+
"message": "Что-то пошло не так. Попробуйте перезагрузить страницу."
163163
},
164164
"styles": {
165165
"message": "Стили"
166166
},
167167
"successfullyImportedSettings": {
168-
"message": "Successfully imported settings"
168+
"message": "Настройки успешно импортированы."
169169
},
170170
"sunsetToSunrise": {
171171
"message": "От заката до рассвета"
@@ -180,10 +180,10 @@
180180
"message": "Страница HOSTNAME защищна браузером."
181181
},
182182
"thisIsAnExperimentalFeatureDoYouWantToActivateIt": {
183-
"message": "This is an experimental feature. Do you want to activate it?"
183+
"message": "Это экспериментальная функция. Вы хотите это активировать?"
184184
},
185185
"thisWillResetAllSettings": {
186-
"message": "This will reset all settings"
186+
"message": "Вы действительно хотите сбросить все настройки?"
187187
},
188188
"timeFrom": {
189189
"message": "Время (от)"

content-scripts.js

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
--------------------------------------------------------------*/
4343

4444
var EXT = {
45-
url: location.href,
45+
url: location.hostname,
46+
styles: [],
4647
elements: {},
4748
values: {},
4849
storage: {},
@@ -840,6 +841,7 @@ function elementStyle(node) {
840841
) {
841842
if (node.sheet) {
842843
EXT.threads++;
844+
EXT.child('added', node);
843845

844846
createStyle(parseRules(node.sheet.cssRules), node.parentNode);
845847
}
@@ -868,6 +870,8 @@ function parseMutations(mutationList) {
868870
if (node.nodeName === 'LINK') {
869871
if (node.rel === 'stylesheet') {
870872
if (ready && getGlobalOrLocale()['dynamic-theme']) {
873+
EXT.child('added', node);
874+
871875
elementLink(node);
872876
}
873877
}
@@ -877,6 +881,12 @@ function parseMutations(mutationList) {
877881
}
878882
}
879883
}
884+
885+
for (var j = 0, k = mutation.removedNodes.length; j < k; j++) {
886+
var node = mutation.removedNodes[j];
887+
888+
EXT.child('removed', node);
889+
}
880890
} else if (mutation.type === 'attributes') {
881891
if (mutation.attributeName === 'style') {
882892
if (ready && getGlobalOrLocale()['dynamic-theme']) {
@@ -949,14 +959,9 @@ function parseRules(rules, parent, url) {
949959
if (EXT.threads === 0 && EXT.ready === false) {
950960
EXT.ready = true;
951961

952-
//queryLinks();
953-
//queryStyles();
954-
955962
document.documentElement.classList.add('dark-mode--ready');
956963
}
957964

958-
queryInlines();
959-
960965
if (url) {
961966
string = string.replace(EXT.regex.url, function (match) {
962967
var result = match.replace(/url\(["']?/, '').replace(/["']?\)$/, '');
@@ -1280,4 +1285,36 @@ EXT.observer.observe(document, {
12801285
],
12811286
childList: true,
12821287
subtree: true
1283-
});
1288+
});
1289+
1290+
1291+
/*--------------------------------------------------------------
1292+
# HANDLERS
1293+
--------------------------------------------------------------*/
1294+
1295+
/*--------------------------------------------------------------
1296+
# CHILD
1297+
--------------------------------------------------------------*/
1298+
1299+
EXT.child = function (type, element) {
1300+
var children = element.children,
1301+
index = EXT.styles.indexOf(element);
1302+
1303+
if (type === 'added') {
1304+
if (index === -1) {
1305+
EXT.styles.push(element);
1306+
}
1307+
} else if (type === 'removed') {
1308+
if (index !== -1) {
1309+
EXT.styles.splice(index, 1);
1310+
}
1311+
}
1312+
1313+
if (children) {
1314+
for (var i = 0, l = children.length; i < l; i++) {
1315+
var child = children[i];
1316+
1317+
EXT.child(type, child);
1318+
}
1319+
}
1320+
};

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 2,
33
"name": "Dark Mode",
4-
"version": "2.0.12",
4+
"version": "2.1.0",
55
"description": "Dark Mode, read at night. Bluelight filter for every website. Relax your eyes at night and day.",
66
"default_locale": "en",
77
"icons": {

options.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
}
1616
</style>
1717
</head>
18-
<body>
18+
<body theme="black">
1919
<link rel="stylesheet" href="satus.css">
2020
<link rel="stylesheet" href="popup.css">
2121
<script src="satus.js"></script>

popup.css

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# BASE
1212
--------------------------------------------------------------*/
1313

14-
html {
14+
body[theme=black] {
1515
--satus-primary: rgb(255, 255, 255, .25);
1616
--satus-modal-background: #2b2e3b;
1717
--satus-modal-text: #dedfe3;
@@ -24,7 +24,8 @@ html {
2424
--satus-switch-track: #454d5f;
2525
--satus-switch-track--active: #375a6c;
2626
--satus-switch-thumb: #c6cad2;
27-
--satus-tabs: #272935;
27+
--satus-tabs-background: #1e2029;
28+
--satus-tabs-foreground: #272935;
2829
}
2930

3031

@@ -43,10 +44,15 @@ html {
4344
# LAYERS
4445
--------------------------------------------------------------*/
4546

47+
.satus-tabs {
48+
width: 100%;
49+
margin: 12px 0 4px;
50+
}
51+
4652
.satus-switch--domain {
47-
width: calc(100% - 24px);
53+
width: 100%;
4854
height: 48px;
49-
margin: 12px auto 0;
55+
margin: 8px auto 0;
5056
padding: 0 16px;
5157
transition: 150ms;
5258
color: #7d95a1;
@@ -66,7 +72,6 @@ html {
6672
}
6773

6874
.satus-alert {
69-
width: calc(100% - 24px);
7075
margin: 12px auto 0;
7176
}
7277

@@ -80,7 +85,7 @@ html {
8085
}
8186

8287
.satus-section--styles {
83-
margin: 8px;
88+
margin: 8px 0;
8489
flex: 1;
8590
}
8691

@@ -100,7 +105,7 @@ html {
100105

101106
.satus-div--website-item {
102107
position: relative;
103-
padding: 0;
108+
padding: 0 !important;
104109
}
105110

106111
.satus-button--favicon {

popup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515
</style>
1616
</head>
17-
<body>
17+
<body theme="black">
1818
<link rel="stylesheet" href="satus.css">
1919
<link rel="stylesheet" href="popup.css">
2020
<script src="satus.js"></script>

0 commit comments

Comments
 (0)