Compare commits
8 Commits
Author | SHA1 | Date |
---|---|---|
clerie | 59a86e30c7 | |
clerie | ac139f6bca | |
Clemens Riese | 1d9d3bb757 | |
clerie | d0a14f0ee5 | |
clerie | 7b9477e386 | |
clerie | 09f8239e9f | |
clerie | cbebbdb817 | |
clerie | 7cf80d38d8 |
|
@ -5,6 +5,10 @@ Dieses Firefox Plugin ersetzt die Daumen in YouTube getreu dem Känguru durch Wi
|
|||
|
||||
# Installation
|
||||
## Firefox
|
||||
### Aus Firefox Add-ons (Empfohlen)
|
||||
Einfach zu Firefox hinzufügen:
|
||||
https://addons.mozilla.org/de/firefox/addon/witzig-nicht-witzig/
|
||||
|
||||
### Als Entwicklerversion
|
||||
1. Herunterladen
|
||||
2. Entpacken
|
||||
|
@ -31,10 +35,6 @@ Funktioniert noch nicht so richtig.
|
|||
4. Entpackte Erweiterung laden
|
||||
5. YouTube aufrufen
|
||||
|
||||
# Disclaimer
|
||||
Die Grafiken der Witzig! und Nicht Witzig! Stempel entstammen des Marc-Uwe-Kling Stickerpacks von Telegram. Ich beanspruche keine Rechte daran.
|
||||
Die Grafiken dienen als Platzhalter und werden in der weiteren Entwicklung durch gemeinfreie ersetzt.
|
||||
|
||||
# Credits
|
||||
- Idee: Maike
|
||||
- Umsetzung: [Clemens Riese](https://clerie.de)
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 979 KiB |
|
@ -2,10 +2,10 @@
|
|||
|
||||
"manifest_version": 2,
|
||||
"name": "Witzig! - Nicht Witzig!",
|
||||
"version": "1.0",
|
||||
"version": "1.2",
|
||||
|
||||
"description": "Replaces the thumb up and down in YouTube with a Witzig! and a Nicht Witzig! stamp.",
|
||||
|
||||
"homepage_url": "https://github.com/clerie/witzig-nicht-witzig/",
|
||||
"icons": {
|
||||
"73": "media/icon-witzig-73.png",
|
||||
"228": "media/icon-witzig-228.png"
|
||||
|
@ -23,10 +23,13 @@
|
|||
],
|
||||
|
||||
"web_accessible_resources": [
|
||||
"media/stempel-witzig.png",
|
||||
"media/stempel-witzig-disabled.png",
|
||||
"media/stempel-nicht-witzig.png",
|
||||
"media/stempel-nicht-witzig-disabled.png"
|
||||
]
|
||||
"media/*"
|
||||
],
|
||||
|
||||
"options_ui": {
|
||||
"page": "settings/index.html"
|
||||
},
|
||||
|
||||
"permissions": ["storage"]
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form>
|
||||
<h2>Ressourcen</h2>
|
||||
<label>
|
||||
<input type="checkbox" id="light">
|
||||
<b>Light Modus</b><br>
|
||||
Verringert die Prozessorlast durch abschalten der interaktiven Elemente
|
||||
</label>
|
||||
<br>
|
||||
<br>
|
||||
<button type="submit">Speichen</button>
|
||||
</form>
|
||||
|
||||
<script src="settings.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,23 @@
|
|||
function saveOptions(e) {
|
||||
e.preventDefault();
|
||||
browser.storage.local.set({
|
||||
light: document.querySelector("#light").checked
|
||||
});
|
||||
}
|
||||
|
||||
function restoreOptions() {
|
||||
|
||||
function setCurrentChoice(result) {
|
||||
document.querySelector("#light").checked = result.light || false;
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
console.log(`Error: ${error}`);
|
||||
}
|
||||
|
||||
var getting = browser.storage.local.get("light");
|
||||
getting.then(setCurrentChoice, onError);
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", restoreOptions);
|
||||
document.querySelector("form").addEventListener("submit", saveOptions);
|
74
witzig.js
74
witzig.js
|
@ -11,6 +11,9 @@ const image_container_path = 'html body ytd-app div#content.style-scope.ytd-app
|
|||
// CSS Pfad, der das Objekt, das die Daumen beinhaltet, beschriebt, um den Bereicht, in dem sich die Grafiken für die Objekte ausbreiten können, zu vergößern
|
||||
const container_path = 'html body ytd-app div#content.style-scope.ytd-app ytd-page-manager#page-manager.style-scope.ytd-app ytd-watch.style-scope.ytd-page-manager.hide-skeleton div#top.style-scope.ytd-watch div#container.style-scope.ytd-watch div#main.style-scope.ytd-watch div#info.style-scope.ytd-watch div#info-contents.style-scope.ytd-watch ytd-video-primary-info-renderer.style-scope.ytd-watch div#container.style-scope.ytd-video-primary-info-renderer div#info.style-scope.ytd-video-primary-info-renderer div#menu-container.style-scope.ytd-video-primary-info-renderer div#menu.style-scope.ytd-video-primary-info-renderer ytd-menu-renderer.style-scope.ytd-video-primary-info-renderer div#top-level-buttons.style-scope.ytd-menu-renderer ytd-toggle-button-renderer.style-scope.ytd-menu-renderer.force-icon-button a.yt-simple-endpoint.style-scope.ytd-toggle-button-renderer yt-icon-button#button.style-scope.ytd-toggle-button-renderer';
|
||||
|
||||
// Css Pfad, der beschreibt, von wo aus clicks zum ändern der Likes interprätiert werden sollen
|
||||
const link_path = 'html body ytd-app div#content.style-scope.ytd-app ytd-page-manager#page-manager.style-scope.ytd-app ytd-watch.style-scope.ytd-page-manager.hide-skeleton div#top.style-scope.ytd-watch div#container.style-scope.ytd-watch div#main.style-scope.ytd-watch div#info.style-scope.ytd-watch div#info-contents.style-scope.ytd-watch ytd-video-primary-info-renderer.style-scope.ytd-watch div#container.style-scope.ytd-video-primary-info-renderer div#info.style-scope.ytd-video-primary-info-renderer div#menu-container.style-scope.ytd-video-primary-info-renderer div#menu.style-scope.ytd-video-primary-info-renderer ytd-menu-renderer.style-scope.ytd-video-primary-info-renderer div#top-level-buttons.style-scope.ytd-menu-renderer ytd-toggle-button-renderer.style-scope.ytd-menu-renderer.force-icon-button a.yt-simple-endpoint.style-scope.ytd-toggle-button-renderer';
|
||||
|
||||
/*
|
||||
Hilfsfunktionen
|
||||
*/
|
||||
|
@ -24,6 +27,10 @@ function getURL(path) {
|
|||
return chrome.runtime.getURL(path) || browser.runtime.getURL(path);
|
||||
}
|
||||
|
||||
function onError(error) {
|
||||
log(`Error: ${error}`);
|
||||
}
|
||||
|
||||
/*
|
||||
Grafikfunktionen
|
||||
*/
|
||||
|
@ -47,38 +54,89 @@ Hauptfunktion
|
|||
*/
|
||||
|
||||
// Ersetzt die Daumen durch Stempel
|
||||
function inject() {
|
||||
function inject(settings) {
|
||||
var container_object = document.querySelectorAll(container_path);
|
||||
resize_container(container_object[0], "100px");
|
||||
resize_container(container_object[1], "100px");
|
||||
log("Stempelfläche vergrößert.");
|
||||
var image_container_object = document.querySelectorAll(image_container_path);
|
||||
log("Packe Stempel aus...");
|
||||
inject_image(image_container_object[0], getURL("media/stempel-witzig.png"));
|
||||
|
||||
// wenn Like aktiv, zeige aktive Grafik an
|
||||
if(container_object[0].classList.contains('style-default-active') || settings.light) {
|
||||
inject_image(image_container_object[0], getURL("media/stempel-witzig.png"));
|
||||
}
|
||||
else {
|
||||
inject_image(image_container_object[0], getURL("media/stempel-witzig-disabled.png"));
|
||||
}
|
||||
log("Witzig!");
|
||||
inject_image(image_container_object[1], getURL("media/stempel-nicht-witzig.png"));
|
||||
|
||||
// wenn Dislike aktiv, zeige aktive Grafik an
|
||||
if(container_object[1].classList.contains('style-default-active') || settings.light) {
|
||||
inject_image(image_container_object[1], getURL("media/stempel-nicht-witzig.png"));
|
||||
}
|
||||
else {
|
||||
inject_image(image_container_object[1], getURL("media/stempel-nicht-witzig-disabled.png"));
|
||||
}
|
||||
log("Nicht Witzig!");
|
||||
}
|
||||
|
||||
// Warte noch kurz vor dem einfügen
|
||||
function inject_with_timeout() {
|
||||
setTimeout(function () {inject({light: false})}, 10);
|
||||
}
|
||||
|
||||
/*
|
||||
Ladefunktion
|
||||
*/
|
||||
|
||||
// regelmäßig prüfen, ob sich die URL geändert hat und entsprechend den Like Status aktualisieren
|
||||
var current_url = '';
|
||||
var last_loaded_url = '';
|
||||
|
||||
var link_object = '';
|
||||
|
||||
function inject_loop () {
|
||||
current_url = window.location.href;
|
||||
if(current_url != last_loaded_url) {
|
||||
log("Neues");
|
||||
setTimeout(function () {inject({light: false})}, 500);
|
||||
last_loaded_url = current_url;
|
||||
}
|
||||
|
||||
setTimeout(inject_loop, 500);
|
||||
}
|
||||
|
||||
// Die YouTube Website läd die Inhalte durch ein externes JavaScript, wenn wir von vornherein unsere eigenen Inhalte einsetzen, werden diese später von YouTube wieder überschrieben. Wir schauen also, ob ein bestimmtes Objekt, dass durch JavaScript eingefügt wird, exstiert, dann erst bringen wir unsere eigenen Inhalte ein.
|
||||
var loaded = false;
|
||||
|
||||
function loading() {
|
||||
function loading(settings) {
|
||||
loaded = document.querySelector(load_end_check_path);
|
||||
if (loaded) {
|
||||
log("Stempelfläche gefunden.");
|
||||
inject();
|
||||
|
||||
if(!settings.light) {
|
||||
// initialisiere onclick events
|
||||
link_object = document.querySelectorAll(link_path);
|
||||
link_object[0].onclick = inject_with_timeout;
|
||||
link_object[1].onclick = inject_with_timeout;
|
||||
|
||||
// starte Schleife, die nach aktualisierungen ausschau hält
|
||||
inject_loop();
|
||||
}
|
||||
else {
|
||||
inject(settings);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
log("Hier nicht.");
|
||||
setTimeout(loading, 100);
|
||||
setTimeout(function () {loading(settings)}, 500);
|
||||
}
|
||||
}
|
||||
|
||||
// Starte das Add-on
|
||||
log("Suche Stempelfläche...");
|
||||
loading();
|
||||
// lade Einstellungen
|
||||
var getting = browser.storage.local.get("light");
|
||||
getting.then(loading, onError);
|
||||
|
|
Loading…
Reference in New Issue