Skip to content

Commit

Permalink
feat: ✨ Added functions.js. Fixed styling on some websites. Added 2li…
Browse files Browse the repository at this point in the history
…b.org to dark mode websites.

Functions.js is a central place for storing functions used when converting any website to dark mode. Added dark mode for 2lib.org. Fixed styling for: dw.com, bbc.com, theguardian.com.
  • Loading branch information
alyn3d committed Apr 13, 2021
1 parent d6ec3fc commit bd4a485
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 9 deletions.
21 changes: 21 additions & 0 deletions src/js/2lib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
addStyle(`
.jscommentsCommentBox, .dropdown-menu > li > a, .moreBtn > div > span {
color: #000000!important;
}
.dropdown-menu .dropdown-menu-muted {
color: #888!important;
}
#searchModeTabs li.active, #searchModeTabs li.active a, #advSearch, .cBox1 a, button span {
color: #000000!important;
}
.b-search-input .button input, .b-search-input .button button > span, {
color: #000000!important;
}
#searchResultBox {
background: #000000;
color: #ffffff!important;
}
div.resItemFuzzyMatch h3 a:link, div.resItemFuzzyMatch h3 a:visited {
color: #ffffff!important;
}
`);
11 changes: 11 additions & 0 deletions src/js/bbc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
addStyle(`
.article__body-content, .author-unit__container {
background-color: #000000;
}
[class$="MenuListContainer"] {
background-color: #000000!important;
}
.lx-c-sticky {
color: #000000;
}
`);
6 changes: 0 additions & 6 deletions src/js/digi24.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ for (i = 0; i < toWhite.length; i++) {
var adjustPadding = document.querySelector('.footer-network-nav');
adjustPadding.style.setProperty('padding-top', '20px');

function addStyle(styleString) {
const style = document.createElement('style');
style.textContent = styleString;
document.head.append(style);
}

addStyle(`
::selection {
color: black;
Expand Down
16 changes: 16 additions & 0 deletions src/js/dw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
addStyle(`
div#footerSection {
border-left: none;
border-right: none;
border-bottom: none;
}
div.adsContainer {
background-color: transparent;
}
div#navMain ul#navLevel1 li div.flyout ul.sitemap li a {
color: #000000!important;
}
div#navMain ul#navLevel1 li a:hover {
color: #000000!important;
}
`);
6 changes: 6 additions & 0 deletions src/js/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

function addStyle(styleString) {
const style = document.createElement('style');
style.textContent = styleString;
document.head.append(style);
}
14 changes: 14 additions & 0 deletions src/js/theguardian.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
addStyle(`
.u-faux-block-link--hover {
background-color: rgba(255,255,255,0.2)!important;
}
.most-viewed-right ~ a {
color: #ffffff!important;
}
body {
color: #ffffff!important;
}
a:-webkit-any-link {
color: #ffffff!important;
}
`);
22 changes: 19 additions & 3 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "DarkMode News",
"action": {},
"manifest_version": 3,
"version": "0.1",
"version": "0.2",
"description": "News Websites will automatically go to dark mode.",
"permissions": [
"activeTab",
Expand All @@ -16,12 +16,28 @@
},
"content_scripts": [
{
"matches": ["*://*.digi24.ro/*", "*://*.theguardian.com/*", "*://*.reuters.com/*", "*://*.bbc.com/*", "*://*.foreignaffairs.com/*", "*://*.dw.com/*", "*://*.ft.com/*", "*://*.chicagotribune.com/*", "*://*.apnews.com/*", "*://*.europa.eu/*"],
"js": ["run.js"]
"matches": ["*://*.digi24.ro/*", "*://*.theguardian.com/*", "*://*.reuters.com/*", "*://*.bbc.com/*", "*://*.foreignaffairs.com/*", "*://*.dw.com/*", "*://*.ft.com/*", "*://*.chicagotribune.com/*", "*://*.apnews.com/*", "*://*.europa.eu/*", "*://*.2lib.org/*"],
"js": ["/js/functions.js", "run.js"]
},
{
"matches": ["*://*.digi24.ro/*"],
"js": ["/js/digi24.js"]
},
{
"matches": ["*://*.dw.com/*"],
"js": ["/js/dw.js"]
},
{
"matches": ["*://*.bbc.com/*"],
"js": ["/js/bbc.js"]
},
{
"matches": ["*://*.theguardian.com/*"],
"js": ["/js/theguardian.js"]
},
{
"matches": ["*://*.2lib.org/*"],
"js": ["/js/2lib.js"]
}
],
"background": {
Expand Down

0 comments on commit bd4a485

Please sign in to comment.