Skip to content

Commit

Permalink
Fixes für die "neue" pietsmiet.de und Code aufgeräumt
Browse files Browse the repository at this point in the history
  • Loading branch information
Saphareas committed Aug 15, 2018
1 parent ad1b046 commit b9241db
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 95 deletions.
71 changes: 23 additions & 48 deletions _shared/darken_ps.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,69 +7,44 @@ iframe,
}

/* Hintergrund und Textfarbe des Video-Containers */
.main .container,
.pagenav {
main.container {
background: #242424 !important;
color: #fff !important;
}
a.pagenav {
color: #0b8043 !important;
}

/* Textfarbe für alle Überschriften */
h1,
h2,
h3,
h4,
h5 {
/* Farben der Navigations-Flyouts */
div.dropdown, div.dropdown > div {
background: #007743 !important;
color: #fff !important;
}

/* Textfarbe für alle Überschriften-Links... */
h1 a:link,
h2 a:link,
h3 a:link,
h4 a:link,
h5 a:link {
/* Farben der Popups (z.B. Datenschutz-Infos) */
.modal,
.modal-header,
.modal-body,
.modal-footer {
background: #242424 !important;
color: #fff !important;
}

/* ...auch die bereits besuchten */
h1 a:visited,
h2 a:visited,
h3 a:visited,
h4 a:visited,
h5 a:visited {
color: #fff !important;
.modal-footer > .button-secondary {
background: darkred;
}

/* Explizit Textfarbe für... */
.latestnews-headline, /* Newsüberschriften */
.ob-rec-text, /* Anzeigenüberschriften */
.breadcrumb li.active, /* aktives Breadcrumb */
.comment-body /* Kommentare */ {
color: #fff !important;
/* Breadcrumbs */
ol.list-reset > div.mr-3 {
color: white;
}

/* Breadcrumbs etwas dunkler/grauer */
.breadcrumb a {
color: #999 !important;
ol.list-reset > li.mr-3.active {
color: white;
text-decoration: underline;
}

/* Break-Farbe von Beige auf Weiß zu Schwarz auf Grau */
hr {
border-top: 1px solid #111111 !important;
border-bottom: 1px solid #242424 !important;
}

/* Playlist-Ansicht */
.media-list-view .table-striped tr:nth-child(odd)>td {
background: #111111 !important;
border-top-color: #111111 !important;
/* Explizit Textfarbe für... */
.media * /* Titel+Text unter Thumbnails */ {
color: #fff !important;
}
.media-list-view .table-striped tr:nth-child(even)>td {
background: #242424 !important;
border-top-color: #242424 !important;
.text-muted /* Untertext unter Artikeln */ {
color: rgba(255, 255, 255, 0.6);
}

/* Profil bearbeiten-Seite */
Expand Down
32 changes: 10 additions & 22 deletions chrome/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ const POD_CSS = chrome.runtime.getURL("darken_podcast.css"); //Voll-qualifiziert
var isFirstLoad = true;

function _podcastHelper() {
var title = document.getElementsByTagName("title")[0].innerText;
var title = document.getElementsByClassName("mr-3 active")[0].innerText;
if (title.includes("Podcast")) {
window.addEventListener("load", function() {_podcastHelper(element2);});
var element2 = document.createElement("link");
element2.setAttribute("id", "darkmode"); //id, um es später wieder zu finden
element2.setAttribute("rel", "stylesheet");
element2.setAttribute("type", "text/css");
element2.setAttribute("href", POD_CSS);
var iFrame = document.getElementById("blockrandom");
iFrame.contentWindow.document.getElementsByTagName("html")[0].appendChild(element2);
console.log("Podcast darkend");
}
}

Expand All @@ -23,39 +23,27 @@ function onToggleMode(request, sender) {
element.setAttribute("rel", "stylesheet");
element.setAttribute("type", "text/css");
element.setAttribute("href", MAIN_CSS);
document.getElementsByTagName("head")[0].appendChild(element); //hänge an den Head an
document.getElementsByTagName("html")[0].appendChild(element); //hänge an das DOM an
if (isFirstLoad) {
window.addEventListener("load", function() {_podcastHelper();});
isFirstLoad = false;
_podcastHelper(); /* wirft fast immer einen Error, aber ohne ist es buggy */
} else {
_podcastHelper();
}

chrome.storage.local.set({isDark: true});
} else { //also wenn auf normal gewechselt werden soll
}
else { //also wenn auf normal gewechselt werden soll
document.getElementById("darkmode").remove(); //entferne vorher erstelltes link-Element aus DOM

var title = document.getElementsByTagName("title")[0].innerText;
var title = document.getElementsByClassName("mr-3 active")[0].innerText;
if (title.includes("Podcast")) {
hasIFrame = document.getElementsByClassName("contentpane")[0].children[0];
if (hasIFrame) {
hasIFrame.contentWindow.document.getElementById("darkmode").remove();
}
var iFrame = document.getElementById("blockrandom");
iFrame.contentWindow.document.getElementById("darkmode").remove();
console.log("Podcast lightend");
}

chrome.storage.local.set({isDark: false});
}
}

chrome.runtime.sendMessage("show the damn icon"); // Sende irgendwas zum Background, um dort die TabID zu haben
chrome.runtime.onMessage.addListener(onToggleMode); //Sobald das Content-Script eine Message erhält, onToggleMode ausführen

// Antworten-Button Fix
window.addEventListener("load", function() { //läuft, wenn die Seite geladen wurde
setTimeout(function() { //1 sec Delay, weil Kommentare erst nachträglich geladen werden
var comments = document.getElementsByClassName("comment-body");
for (i=0; i < comments.length; i++) {
comments[i].parentNode.children[2].setAttribute("class","comments-buttons");
}
}, 1000);
});
2 changes: 1 addition & 1 deletion chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Pietsmiet.de Dark Mode",
"version": "17.4",
"version": "17.5",
"author": "Fabian Große/Saphareas",
"homepage_url": "https://github.com/Saphareas/pietsmiet.de-Dark-Mode",

Expand Down
2 changes: 1 addition & 1 deletion edge/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Pietsmiet.de Dark Mode",
"version": "17.4",
"version": "17.5",
"author": "Fabian Große/Saphareas",
"homepage_url": "https://github.com/Saphareas/pietsmiet.de-Dark-Mode",

Expand Down
32 changes: 10 additions & 22 deletions firefox/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ const POD_CSS = browser.runtime.getURL("darken_podcast.css"); //Voll-qualifizier
var isFirstLoad = true;

function _podcastHelper() {
var title = document.getElementsByTagName("title")[0].innerText;
var title = document.getElementsByClassName("mr-3 active")[0].innerText;
if (title.includes("Podcast")) {
window.addEventListener("load", function() {_podcastHelper(element2);});
var element2 = document.createElement("link");
element2.setAttribute("id", "darkmode"); //id, um es später wieder zu finden
element2.setAttribute("rel", "stylesheet");
element2.setAttribute("type", "text/css");
element2.setAttribute("href", POD_CSS);
var iFrame = document.getElementById("blockrandom");
iFrame.contentWindow.document.getElementsByTagName("html")[0].appendChild(element2);
console.log("Podcast darkend");
}
}

Expand All @@ -23,39 +23,27 @@ function onToggleMode(request, sender) {
element.setAttribute("rel", "stylesheet");
element.setAttribute("type", "text/css");
element.setAttribute("href", MAIN_CSS);
document.getElementsByTagName("html")[0].appendChild(element); //hänge an den Head an
document.getElementsByTagName("html")[0].appendChild(element); //hänge an das DOM an
if (isFirstLoad) {
window.addEventListener("load", function() {_podcastHelper();});
isFirstLoad = false;
_podcastHelper(); /* wirft fast immer einen Error, aber ohne ist es buggy */
} else {
_podcastHelper();
}

browser.storage.local.set({isDark: true});
} else { //also wenn auf normal gewechselt werden soll
}
else { //also wenn auf normal gewechselt werden soll
document.getElementById("darkmode").remove(); //entferne vorher erstelltes link-Element aus DOM

var title = document.getElementsByTagName("title")[0].innerText;
var title = document.getElementsByClassName("mr-3 active")[0].innerText;
if (title.includes("Podcast")) {
hasIFrame = document.getElementsByClassName("contentpane")[0].children[0];
if (hasIFrame) {
hasIFrame.contentWindow.document.getElementById("darkmode").remove();
}
var iFrame = document.getElementById("blockrandom");
iFrame.contentWindow.document.getElementById("darkmode").remove();
console.log("Podcast lightend");
}

browser.storage.local.set({isDark: false});
}
}

browser.runtime.sendMessage("show the damn icon"); // Sende irgendwas zum Background, um dort die TabID zu haben
browser.runtime.onMessage.addListener(onToggleMode); //Sobald das Content-Script eine Message erhält, onToggleMode ausführen

// Antworten-Button Fix
window.addEventListener("load", function() { //läuft, wenn die Seite geladen wurde
setTimeout(function() { //1 sec Delay, weil Kommentare erst nachträglich geladen werden
var comments = document.getElementsByClassName("comment-body");
for (i=0; i < comments.length; i++) {
comments[i].parentNode.children[2].setAttribute("class","comments-buttons");
}
}, 1000);
});
2 changes: 1 addition & 1 deletion firefox/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Pietsmiet.de Dark Mode",
"version": "17.4",
"version": "17.5",
"author": "Fabian Große/Saphareas",
"homepage_url": "https://github.com/Saphareas/pietsmiet.de-Dark-Mode",

Expand Down

0 comments on commit b9241db

Please sign in to comment.