Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ability to change to dark/light mode based on user prefence #533

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
40 changes: 40 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# CONTRIBUTING

Everyone is welcome to contribute to Facebook Containers. Reach out to team members if you have questions:

- IRC: #containers on irc.mozilla.org
- Email: [email protected]

## Filing bugs

If you find a bug with Facebook Container, please file a issue.

Check first if the bug might already exist: https://github.com/mozilla/contain-facebook/issues

[Open an issue](https://github.com/mozilla/contain-facebook/issues/new)

1. Visit about:support
2. Click "Copy raw data to clipboard" and paste into the bug. Alternatively copy the following sections into the issue:
- Application Basics
- Nightly Features (if you are in nightly)
- Extensions
- Experimental Features
3. Include clear steps to reproduce the issue you have experienced.
4. Include screenshots if possible.
*****

## Sending Pull Requests

Patches should be submitted as pull requests. When submitting patches as PRs:

- You agree to license your code under the project's open source license (MPL 2.0).
- Base your branch off the current master (see below for an example workflow).
- Add both your code and new tests if relevant.
- Run `npm test` to make sure all tests still pass.
- Please do not include merge commits in pull requests; include only commits with the new relevant code.

See the main [README](https://github.com/mozilla/contain-facebook/blob/master/README.md) for information on prerequisites, installing, running and testing.




3 changes: 2 additions & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"storage",
"tabs",
"webRequestBlocking",
"webRequest"
"webRequest",
"theme"
],

"background": {
Expand Down
3 changes: 2 additions & 1 deletion src/panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ a:hover {

.highlight-on-hover span {
pointer-events: none;

}

.allowed-site-wrapper {
Expand Down Expand Up @@ -218,7 +219,7 @@ a:hover {

.allowed-site-wrapper:hover,
.highlight-on-hover:hover {
background-color: var(--grey20);
background-color: rgb(94, 141, 230);
transition: var(--transition);
}

Expand Down
1 change: 1 addition & 0 deletions src/panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<title>Facebook Container</title>
<link rel="stylesheet" href="panel.css">
<script src="panel.js"></script>
<script src="theme-change.js"></script>
</head>
<body class="panel">
</body>
Expand Down
26 changes: 26 additions & 0 deletions src/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,36 @@ const addFullWidthButton = (fragment, listenerClass) => {

let contentWrapper = addDiv(fragment, "fw-bottom-btn");
contentWrapper.appendChild(button);
//adds the ability to change background text color to suit the current theme color
/* eslint-disable indent */
function style(themeInfo) {
if (themeInfo.colors)
{
const link_button=document.getElementsByClassName("highlight-on-hover");
for(var i=0;i<link_button.length;i++){
link_button[i].style.color =themeInfo.colors.tab_background_text;
}
}

}
async function getThemeInfo()
{
var themeInfo = await browser.theme.getCurrent();

style(themeInfo);
}

getThemeInfo();
return button;
};








const addSpan = (wrapper, stringId) => {
const span = document.createElement("span");
span["id"] = stringId;
Expand Down
27 changes: 27 additions & 0 deletions src/theme-change.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* eslint-disable indent */
function getStyle(themeInfo)
{
if (themeInfo.colors) {

document.body.style.backgroundColor= themeInfo.colors.toolbar;
document.body.style.color=themeInfo.colors.tab_background_text;

const link_button=document.getElementsByClassName("highlight-on-hover");
for(var i=0;i<link_button.length;i++){
link_button[i].style.color =themeInfo.colors.tab_background_text;
}
}

}


async function getCurrentThemeInfo()
{
var themeInfo = await browser.theme.getCurrent();

getStyle(themeInfo);
}

getCurrentThemeInfo();