Skip to content

Commit 63ce196

Browse files
committed
Added shadow color
1 parent 3d0940b commit 63ce196

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

Selection_styler.zip

316 Bytes
Binary file not shown.

background.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ function restoreOptions() {
55
};
66

77
function setCurrentChoice(result) {
8-
var css = '::selection { background: ' + result.background_color + '; color: ' + result.color + /*'; text-decoration: ' + result.underline + */'}';
8+
if (result.shadowActivated) {
9+
var css = '::selection { background: ' + result.background_color + '; color: ' + result.color + '; text-shadow: ' + result.shadowColor + ' 0px 0px 15px}';
10+
} else {
11+
var css = '::selection { background: ' + result.background_color + '; color: ' + result.color + '; text-shadow: }';
12+
}
913
console.log(css);
1014
browser.tabs.insertCSS({code: css});
1115
};

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33
"name": "Selection styler",
44
"author": "Pythack",
5-
"version": "1.1.3",
5+
"version": "1.1.7",
66
"description": "Change the color and background color of the selection",
77
"background": {
88
"scripts": ["./background.js"]

popup.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ function saveOptions(e) {
1212
e.preventDefault();
1313
let preferencesSave = browser.storage.local.set({
1414
background_color: document.querySelector("#background_color").value || "#007ef3",
15-
color: document.querySelector("#color").value || "white"//,
16-
/*shadowActivated: document.querySelector("input#activate_textShadow").checked || false,
17-
shadowColor: document.querySelector("#shadow-color").value || "none"*/
15+
color: document.querySelector("#color").value || "white",
16+
shadowActivated: document.querySelector("input#activate_textShadow").checked || false,
17+
shadowColor: document.querySelector("#shadow-color").value || "none"
1818
//fontSize: document.querySelector("#font-size").value || "auto",
1919
});
2020
preferencesSave.then(saveSuccess, saveError)
@@ -26,9 +26,11 @@ function saveOptions(e) {
2626
function updatePreview() {
2727
document.querySelector("#preview").style.background = document.querySelector("#background_color").value;
2828
document.querySelector("#preview").style.color = document.querySelector("#color").value;
29-
/*if (document.querySelector("input#activate_textShadow").checked) {
29+
if (document.querySelector("input#activate_textShadow").checked) {
3030
document.querySelector("#preview").style.textShadow = document.querySelector("#shadow-color").value + " 0px 0px 15px";
31-
}*/
31+
} else {
32+
document.querySelector("#preview").style.textShadow = "";
33+
}
3234
}
3335

3436
function restoreOptions() {
@@ -38,6 +40,12 @@ function restoreOptions() {
3840
document.querySelector("#color-picker-backgroundColor").value = result.background_color || "#007ef3";
3941
document.querySelector("#color").value = result.color || "white";
4042
document.querySelector("#color-picker-textColor").value = result.color || "#ffffff";
43+
document.querySelector("#shadow-color").value = result.shadowColor || "#ffffff";
44+
document.querySelector("input#color-picker-shadowColor").value = result.shadowColor;
45+
document.querySelector("input#activate_textShadow").checked = result.shadowActivated;
46+
if (result.shadowActivated) {
47+
document.querySelector('div#textSadowOptions').style.display = "block";
48+
}
4149
}
4250

4351
function onError(error) {
@@ -47,9 +55,11 @@ function restoreOptions() {
4755
function updatePreview() {
4856
document.querySelector("#preview").style.background = document.querySelector("#background_color").value;
4957
document.querySelector("#preview").style.color = document.querySelector("#color").value;
50-
/*if (document.querySelector("input#activate_textShadow").checked) {
58+
if (document.querySelector("input#activate_textShadow").checked) {
5159
document.querySelector("#preview").style.textShadow = document.querySelector("#shadow-color").value + " 0px 0px 15px";
52-
}*/
60+
} else {
61+
document.querySelector("#preview").style.textShadow = "";
62+
}
5363
}
5464

5565
let getting = browser.storage.local.get();
@@ -78,7 +88,7 @@ function updateBackgroundColorInputColor() {
7888
document.querySelector("input#color-picker-backgroundColor").value = color;
7989
}
8090

81-
/*function updateShadowColorInput() {
91+
function updateShadowColorInput() {
8292
var color = document.querySelector("input#color-picker-shadowColor").value;
8393
document.querySelector("input#shadow-color").value = color;
8494
}
@@ -94,21 +104,21 @@ function updateShadowColorDisplay() {
94104
} else {
95105
document.querySelector('div#textSadowOptions').style.display = "none";
96106
}
97-
}*/
107+
}
98108

99109
document.addEventListener("DOMContentLoaded", restoreOptions);
100110
document.addEventListener("DOMContentLoaded", updatePreview);
101111
document.querySelector("form").addEventListener("submit", saveOptions);
102112
document.querySelector("form").addEventListener("keyup", updatePreview);
103113
document.querySelector("form").addEventListener("input", updatePreview);
104-
//document.querySelector("input#activate_textShadow").addEventListener("change", updatePreview);
114+
document.querySelector("input#activate_textShadow").addEventListener("change", updatePreview);
105115
document.querySelector("input#color-picker-textColor").addEventListener("input", updateColorInput);
106116
document.querySelector("input#color-picker-backgroundColor").addEventListener("input", updateBackgroundColorInput);
107117
document.querySelector("input#color").addEventListener("input", updateColorInputColor);
108118
document.querySelector("input#background_color").addEventListener("input", updateBackgroundColorInputColor);
109-
/*document.querySelector("input#color-picker-shadowColor").addEventListener("input", updateShadowColorInput);
119+
document.querySelector("input#color-picker-shadowColor").addEventListener("input", updateShadowColorInput);
110120
document.querySelector("input#shadow-color").addEventListener("input", updateShadowColorInputColor);
111-
document.querySelector("input#activate_textShadow").addEventListener("change", updateShadowColorDisplay);*/
121+
document.querySelector("input#activate_textShadow").addEventListener("change", updateShadowColorDisplay);
112122

113123
/*browser.tabs.create({
114124
url:browser.extension.getURL('./popup.html')

0 commit comments

Comments
 (0)