add style options
This commit is contained in:
1 parent
8317f44270
commit
d4ce7bd968
4 files changed
+82
-4
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "nazeka",
|
"name": "nazeka",
|
||||||
"version": "0.2.6.0",
|
"version": "0.2.6.1",
|
||||||
"author": "Wareya",
|
"author": "Wareya",
|
||||||
"homepage_url": "https://github.com/wareya/nazeka",
|
"homepage_url": "https://github.com/wareya/nazeka",
|
||||||
"description": "A rikai replacement.",
|
"description": "A rikai replacement.",
|
||||||
|
|||||||
+46
@@ -167,12 +167,15 @@ function defaults()
|
|||||||
default: false,
|
default: false,
|
||||||
label: "Fixed width"
|
label: "Fixed width"
|
||||||
});
|
});
|
||||||
|
/*
|
||||||
|
// currently broken
|
||||||
settings.push({
|
settings.push({
|
||||||
id: "fixedwidthpositioning",
|
id: "fixedwidthpositioning",
|
||||||
kind: "checkbox",
|
kind: "checkbox",
|
||||||
default: false,
|
default: false,
|
||||||
label: "Position as though fixed width (currently nonfunctional; will fix later)"
|
label: "Position as though fixed width (currently nonfunctional; will fix later)"
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
settings.push({
|
settings.push({
|
||||||
id: "corner",
|
id: "corner",
|
||||||
kind: "combobox",
|
kind: "combobox",
|
||||||
@@ -312,6 +315,49 @@ function defaults()
|
|||||||
label: "Reader autoscroll leeway (when \"insert at bottom\" is enabled) (0 disables)"
|
label: "Reader autoscroll leeway (when \"insert at bottom\" is enabled) (0 disables)"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
settings.push({
|
||||||
|
id: "reader_bg",
|
||||||
|
kind: "color",
|
||||||
|
default: "#111111",
|
||||||
|
label: "Reader background color"
|
||||||
|
});
|
||||||
|
settings.push({
|
||||||
|
id: "reader_fg",
|
||||||
|
kind: "color",
|
||||||
|
default: "#CCCCCC",
|
||||||
|
label: "Reader text color"
|
||||||
|
});
|
||||||
|
settings.push({
|
||||||
|
id: "reader_font_size",
|
||||||
|
kind: "text",
|
||||||
|
default: "1.4em",
|
||||||
|
label: "Reader text size"
|
||||||
|
});
|
||||||
|
settings.push({
|
||||||
|
id: "reader_right_padding",
|
||||||
|
kind: "text",
|
||||||
|
default: "0px",
|
||||||
|
label: "Reader right padding (useful if you use 'sticky' mode)"
|
||||||
|
});
|
||||||
|
settings.push({
|
||||||
|
id: "reader_max_width",
|
||||||
|
kind: "text",
|
||||||
|
default: "1000px",
|
||||||
|
label: "Reader max width"
|
||||||
|
});
|
||||||
|
settings.push({
|
||||||
|
id: "reader_margin",
|
||||||
|
kind: "text",
|
||||||
|
default: "8px",
|
||||||
|
label: "Reader left/right margins"
|
||||||
|
});
|
||||||
|
settings.push({
|
||||||
|
id: "reader_font",
|
||||||
|
kind: "text",
|
||||||
|
default: "",
|
||||||
|
label: "Reader font override (without trailing comma)"
|
||||||
|
});
|
||||||
|
|
||||||
// hotkeys
|
// hotkeys
|
||||||
settings.push({
|
settings.push({
|
||||||
kind: "dummy",
|
kind: "dummy",
|
||||||
|
|||||||
+1
-1
@@ -7,7 +7,7 @@ body
|
|||||||
{
|
{
|
||||||
background-color: #111;
|
background-color: #111;
|
||||||
color: #CCC;
|
color: #CCC;
|
||||||
font-family: Verdana, Arial, IPAGothic, TakaoGothic, Noto Sans CJK JP Regular, Meiryo, sans-serif;
|
font-family: Verdana, Arial, IPAGothic, Noto Sans CJK JP Regular, TakaoGothic, Meiryo, sans-serif;
|
||||||
font-size: 1.4em;
|
font-size: 1.4em;
|
||||||
}
|
}
|
||||||
html
|
html
|
||||||
|
|||||||
@@ -2,14 +2,33 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// updated by a timer looping function, based on local storage set by the options page
|
|
||||||
// we only use a tiny number of settings here
|
// we only use a tiny number of settings here
|
||||||
|
|
||||||
let reader_settings = {
|
let reader_settings = {
|
||||||
reader_reverse: false,
|
reader_reverse: false,
|
||||||
reader_leeway: 200
|
reader_leeway: 200,
|
||||||
|
reader_bg: "#111111",
|
||||||
|
reader_fg: "#CCCCCC",
|
||||||
|
reader_font_size: "1.4em",
|
||||||
|
reader_right_padding: "0px",
|
||||||
|
reader_max_width: "1000px",
|
||||||
|
reader_margin: "8px",
|
||||||
|
reader_font: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function update_styles()
|
||||||
|
{
|
||||||
|
let target = document.body.style;
|
||||||
|
target.backgroundColor = reader_settings.reader_bg;
|
||||||
|
target.color = reader_settings.reader_fg;
|
||||||
|
target.fontSize = reader_settings.reader_font_size;
|
||||||
|
target.paddingRight = reader_settings.reader_right_padding;
|
||||||
|
target.maxWidth = reader_settings.reader_max_width;
|
||||||
|
target.marginLeft = reader_settings.reader_margin;
|
||||||
|
target.marginRight = reader_settings.reader_margin;
|
||||||
|
target.fontFamily = reader_settings.reader_font;
|
||||||
|
}
|
||||||
|
|
||||||
async function reader_settings_init()
|
async function reader_settings_init()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -23,6 +42,13 @@ async function reader_settings_init()
|
|||||||
}
|
}
|
||||||
getvar("reader_reverse", false);
|
getvar("reader_reverse", false);
|
||||||
getvar("reader_leeway", 200);
|
getvar("reader_leeway", 200);
|
||||||
|
getvar("reader_bg", "#111111");
|
||||||
|
getvar("reader_fg", "#CCCCCC");
|
||||||
|
getvar("reader_font_size","1.4em");
|
||||||
|
getvar("reader_right_padding", "0px");
|
||||||
|
getvar("reader_max_width", "1000px");
|
||||||
|
getvar("reader_margin", "8px");
|
||||||
|
getvar("reader_font", "");
|
||||||
} catch(err) {} // options not stored yet
|
} catch(err) {} // options not stored yet
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,6 +64,7 @@ browser.storage.onChanged.addListener((updates, storageArea) =>
|
|||||||
if(Object.keys(reader_settings).includes(option))
|
if(Object.keys(reader_settings).includes(option))
|
||||||
reader_settings[option] = value.newValue;
|
reader_settings[option] = value.newValue;
|
||||||
}
|
}
|
||||||
|
update_styles();
|
||||||
});
|
});
|
||||||
|
|
||||||
// actual reder code
|
// actual reder code
|
||||||
@@ -81,7 +108,10 @@ let reader_text_previous = "";
|
|||||||
function reader_cycle_text(text)
|
function reader_cycle_text(text)
|
||||||
{
|
{
|
||||||
if(text != "" && text != reader_text_previous)
|
if(text != "" && text != reader_text_previous)
|
||||||
|
{
|
||||||
reader_update(text);
|
reader_update(text);
|
||||||
|
update_styles();
|
||||||
|
}
|
||||||
reader_text_previous = text;
|
reader_text_previous = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,3 +140,5 @@ browser.runtime.onMessage.addListener((req, sender) =>
|
|||||||
reader_cycle_text(req.text);
|
reader_cycle_text(req.text);
|
||||||
return Promise.resolve(undefined);
|
return Promise.resolve(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.onload = update_styles;
|
||||||
Reference in new issue
Block a user