193 lines
8.0 KiB
JavaScript
193 lines
8.0 KiB
JavaScript
// ==UserScript==
|
|
// @name Crunchyroll Quiz OneTrust Fix
|
|
// @namespace https://git.ponywave.de/Akamaru/Userscripts
|
|
// @version 1.0
|
|
// @description Zeigt einen Button zum Setzen der OneTrust-Cookies, wenn Crunchyroll News Quizzes durch Cookie-Blocker nicht angezeigt werden.
|
|
// @author Akamaru
|
|
// @match https://www.crunchyroll.com/news/quizzes/*
|
|
// @match https://www.crunchyroll.com/*/news/quizzes/*
|
|
// @icon https://www.google.com/s2/favicons?domain=crunchyroll.com&sz=32
|
|
// @grant none
|
|
// @updateURL https://git.ponywave.de/Akamaru/Userscripts/raw/branch/master/crunchyroll-quiz-onetrust-fix.user.js
|
|
// @downloadURL https://git.ponywave.de/Akamaru/Userscripts/raw/branch/master/crunchyroll-quiz-onetrust-fix.user.js
|
|
// ==/UserScript==
|
|
|
|
(function() {
|
|
'use strict';
|
|
|
|
console.log('[Crunchyroll Quiz Fix] Script loaded');
|
|
|
|
// Wartezeit bevor der Button angezeigt wird (in Millisekunden)
|
|
const DETECTION_DELAY = 1000;
|
|
|
|
// Placeholder-Text, der erscheint, wenn OneTrust blockiert wird
|
|
const PLACEHOLDER_TEXT = 'This content is provided by third-party services';
|
|
|
|
// Funktion zum Setzen der OneTrust-Cookies
|
|
function setOneTrustCookies() {
|
|
const timestamp = new Date().toISOString();
|
|
const consentDate = encodeURIComponent(timestamp);
|
|
|
|
// Generiere eine eindeutige Consent-ID
|
|
const consentId = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
const r = Math.random() * 16 | 0;
|
|
const v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
return v.toString(16);
|
|
});
|
|
|
|
// OneTrust Consent Cookie - alle Kategorien akzeptiert
|
|
const optanonConsent = `isGpcEnabled=0&datestamp=${consentDate}&version=202409.1.0&browserGpcFlag=0&isIABGlobal=false&hosts=&consentId=${consentId}&interactionCount=1&landingPath=NotLandingPage&groups=C0001:1,C0002:1,C0003:1,C0004:1&AwaitingReconsent=false`;
|
|
|
|
// Cookie-Ablaufdatum auf 1 Jahr setzen
|
|
const expires = new Date();
|
|
expires.setFullYear(expires.getFullYear() + 1);
|
|
|
|
// Cookies setzen
|
|
document.cookie = `OptanonConsent=${optanonConsent}; path=/; domain=.crunchyroll.com; expires=${expires.toUTCString()}; SameSite=Lax`;
|
|
document.cookie = `OptanonAlertBoxClosed=${timestamp}; path=/; domain=.crunchyroll.com; expires=${expires.toUTCString()}; SameSite=Lax`;
|
|
|
|
console.log('[Crunchyroll Quiz Fix] OneTrust cookies set successfully');
|
|
}
|
|
|
|
// Funktion zum Erstellen und Anzeigen des Buttons
|
|
function showConsentButton(container) {
|
|
console.log('[Crunchyroll Quiz Fix] Replacing placeholder with consent button');
|
|
|
|
// Erstelle den Button-Container mit Styling
|
|
container.innerHTML = `
|
|
<div style="
|
|
padding: 30px;
|
|
text-align: center;
|
|
border: 2px solid #f47521;
|
|
border-radius: 8px;
|
|
background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
|
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
|
max-width: 600px;
|
|
margin: 0 auto;
|
|
">
|
|
<div style="margin-bottom: 20px;">
|
|
<svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg" style="margin-bottom: 15px;">
|
|
<circle cx="32" cy="32" r="30" stroke="#f47521" stroke-width="3" fill="none"/>
|
|
<path d="M32 20V34M32 42V42.5" stroke="#f47521" stroke-width="4" stroke-linecap="round"/>
|
|
</svg>
|
|
</div>
|
|
|
|
<h3 style="color: #f47521; margin: 0 0 15px 0; font-size: 22px; font-weight: bold;">
|
|
Quiz wird blockiert
|
|
</h3>
|
|
|
|
<p style="color: #ccc; margin: 0 0 20px 0; font-size: 15px; line-height: 1.6;">
|
|
Eine Browser-Extension oder dein Ad-Blocker<br>
|
|
blockiert das benötigte Cookie-Consent-Script.
|
|
</p>
|
|
|
|
<p style="color: #fff; margin: 0 0 25px 0; font-size: 14px;">
|
|
Klicke auf den Button, um die notwendigen Cookies zu setzen<br>
|
|
und das Quiz zu laden.
|
|
</p>
|
|
|
|
<button id="cr-quiz-consent-btn" style="
|
|
background: linear-gradient(135deg, #f47521 0%, #ff8c42 100%);
|
|
color: #fff;
|
|
border: none;
|
|
padding: 15px 40px;
|
|
font-size: 18px;
|
|
font-weight: bold;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
box-shadow: 0 4px 12px rgba(244, 117, 33, 0.4);
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
"
|
|
onmouseover="this.style.transform='translateY(-2px)'; this.style.boxShadow='0 6px 16px rgba(244, 117, 33, 0.6)';"
|
|
onmouseout="this.style.transform='translateY(0)'; this.style.boxShadow='0 4px 12px rgba(244, 117, 33, 0.4)';">
|
|
🍪 Cookies akzeptieren & Quiz laden
|
|
</button>
|
|
|
|
<p style="color: #999; margin: 25px 0 0 0; font-size: 12px; line-height: 1.5;">
|
|
<strong>Alternative:</strong> Deaktiviere Cookie-Blocker-Extensions<br>
|
|
für diese Seite und lade sie neu.
|
|
</p>
|
|
</div>
|
|
`;
|
|
|
|
// Button-Click-Handler
|
|
const button = document.getElementById('cr-quiz-consent-btn');
|
|
if (button) {
|
|
button.addEventListener('click', () => {
|
|
console.log('[Crunchyroll Quiz Fix] User clicked consent button');
|
|
|
|
// Zeige Lade-Animation
|
|
button.textContent = '⏳ Cookies werden gesetzt...';
|
|
button.disabled = true;
|
|
button.style.opacity = '0.7';
|
|
button.style.cursor = 'wait';
|
|
|
|
// Setze Cookies
|
|
setOneTrustCookies();
|
|
|
|
// Kurz warten, dann Seite neu laden
|
|
setTimeout(() => {
|
|
button.textContent = '✓ Seite wird neu geladen...';
|
|
setTimeout(() => {
|
|
location.reload();
|
|
}, 500);
|
|
}, 500);
|
|
});
|
|
}
|
|
}
|
|
|
|
// Funktion zum Überprüfen und Ersetzen des Placeholders
|
|
function checkAndReplacePlaceholder() {
|
|
const riddleContainer = document.querySelector('.riddleembed_riddleembed__7dckr');
|
|
|
|
if (!riddleContainer) {
|
|
console.log('[Crunchyroll Quiz Fix] No quiz container found on this page');
|
|
return;
|
|
}
|
|
|
|
// Prüfe, ob der Placeholder-Text vorhanden ist
|
|
if (riddleContainer.textContent.includes(PLACEHOLDER_TEXT)) {
|
|
console.log('[Crunchyroll Quiz Fix] Placeholder detected, showing consent button');
|
|
showConsentButton(riddleContainer);
|
|
} else {
|
|
console.log('[Crunchyroll Quiz Fix] Quiz loaded correctly or different content');
|
|
}
|
|
}
|
|
|
|
// Observer für dynamische Inhaltsänderungen
|
|
function setupMutationObserver() {
|
|
const observer = new MutationObserver(() => {
|
|
checkAndReplacePlaceholder();
|
|
});
|
|
|
|
// Warte auf das Body-Element
|
|
if (document.body) {
|
|
observer.observe(document.body, {
|
|
childList: true,
|
|
subtree: true
|
|
});
|
|
console.log('[Crunchyroll Quiz Fix] MutationObserver started');
|
|
}
|
|
}
|
|
|
|
// Initialisierung
|
|
function init() {
|
|
// Warte kurz, damit die Seite laden kann
|
|
setTimeout(() => {
|
|
checkAndReplacePlaceholder();
|
|
setupMutationObserver();
|
|
}, DETECTION_DELAY);
|
|
}
|
|
|
|
// Starte das Script, wenn DOM bereit ist
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', init);
|
|
} else {
|
|
init();
|
|
}
|
|
|
|
console.log('[Crunchyroll Quiz Fix] Initialization complete');
|
|
})();
|