-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a light-foreground theme for dark backgrounds.
This requires an options page, because the browser doesn't report the background color to extensions. Also, restore the "applications" section in the manifest, because Firefox says it's needed for storage.sync to work. Fixes #33
- Loading branch information
1 parent
2c20c30
commit c24f7d7
Showing
4 changed files
with
276 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<!-- | ||
Copyright (C) 2017 Paul Marks http://www.pmarks.net/ | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<style type="text/css"> | ||
table, td, tr { | ||
border-width: 1px; | ||
border-collapse: collapse; | ||
border-color: #888; | ||
border-style: solid; | ||
padding: 0; | ||
} | ||
label { | ||
display: flex; | ||
padding: 1em; | ||
align-items: center; | ||
} | ||
input[type="radio"] { | ||
margin-right: 1em; | ||
} | ||
.darkfg_frame { | ||
background-color: #f2f2f2; | ||
font-size: 0; | ||
padding: 8px; | ||
} | ||
.lightfg_frame { | ||
background-color: #505050; | ||
font-size: 0; | ||
padding: 8px; | ||
} | ||
.colorscheme_title { | ||
padding: 1em; | ||
font-weight: bold; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<form name="optionsForm"> | ||
<h1>Color Scheme</h1> | ||
<table> | ||
<tr> | ||
<td class="colorscheme_title">Regular tabs:</td> | ||
<td> | ||
<label> | ||
<input type="radio" name="regularColorScheme" value="darkfg" class="disabler"> | ||
<div class="darkfg_frame"> | ||
<canvas id="regularColorScheme:darkfg" width="16px" height="16px"></canvas> | ||
</div> | ||
</label> | ||
</td> | ||
<td> | ||
<label> | ||
<input type="radio" name="regularColorScheme" value="lightfg" class="disabler"> | ||
<div class="lightfg_frame"> | ||
<canvas id="regularColorScheme:lightfg" width="16px" height="16px"></canvas> | ||
</div> | ||
</label> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td class="colorscheme_title">Incognito tabs:</td> | ||
<td> | ||
<label> | ||
<input type="radio" name="incognitoColorScheme" value="darkfg" class="disabler"> | ||
<div class="darkfg_frame"> | ||
<canvas id="incognitoColorScheme:darkfg" width="16px" height="16px"></canvas> | ||
</div> | ||
</label> | ||
</td> | ||
<td> | ||
<label> | ||
<input type="radio" name="incognitoColorScheme" value="lightfg" class="disabler"> | ||
<div class="lightfg_frame"> | ||
<canvas id="incognitoColorScheme:lightfg" width="16px" height="16px"></canvas> | ||
</div> | ||
</label> | ||
</td> | ||
</tr> | ||
</table> | ||
</form> | ||
|
||
<div style="display:inline-block; padding-top:1.5em; width:100%"> | ||
<button id="revert_btn" style="float:left" class="disabler">Revert to Defaults</button> | ||
<button id="dismiss_btn" style="float:right">Dismiss</button> | ||
</div> | ||
|
||
<script src="options.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
Copyright (C) 2017 Paul Marks http://www.pmarks.net/ | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
const bg = chrome.extension.getBackgroundPage(); | ||
const colorSchemeOptions = ["regularColorScheme", "incognitoColorScheme"]; | ||
|
||
function disableAll(disabled) { | ||
for (const e of document.getElementsByClassName("disabler")) { | ||
e.disabled = disabled; | ||
} | ||
} | ||
|
||
function copyOptionsToForm() { | ||
for (const option of colorSchemeOptions) { | ||
const radio = document.optionsForm[option]; | ||
radio.value = bg.options[option]; | ||
} | ||
} | ||
|
||
document.optionsForm.onchange = function(evt) { | ||
const options = {}; | ||
for (const option of colorSchemeOptions) { | ||
options[option] = document.optionsForm[option].value; | ||
} | ||
disableAll(true); | ||
bg.setOptions(options, function() { | ||
disableAll(false); | ||
}); | ||
}; | ||
|
||
document.getElementById("revert_btn").onclick = function() { | ||
disableAll(true); | ||
bg.clearOptions(function() { | ||
copyOptionsToForm(); | ||
disableAll(false); | ||
}); | ||
}; | ||
|
||
document.getElementById("dismiss_btn").onclick = function() { | ||
window.close(); | ||
}; | ||
|
||
for (const option of colorSchemeOptions) { | ||
for (const color of ["darkfg", "lightfg"]) { | ||
const canvas = document.getElementById(option + ":" + color); | ||
const ctx = canvas.getContext("2d"); | ||
const imageData = bg.buildIcon("646", 16, color); | ||
ctx.putImageData(imageData, 0, 0); | ||
} | ||
} | ||
|
||
disableAll(true); | ||
bg.loadOptions(function() { | ||
copyOptionsToForm(); | ||
disableAll(false); | ||
}); |