423 lines
13 KiB
JavaScript
423 lines
13 KiB
JavaScript
// ==UserScript==
|
|
// @name Serienfans/Filmfans Releasegruppen Filter
|
|
// @namespace https://git.ponywave.de/Akamaru/Userscripts
|
|
// @version 1.3
|
|
// @description Blende Uploads bestimmter Releasegruppen aus
|
|
// @author Akamaru
|
|
// @match https://serienfans.org/*
|
|
// @match https://serienfreaks.org/*
|
|
// @match https://filmfans.org/*
|
|
// @icon https://www.google.com/s2/favicons?domain=serienfans.org&sz=32
|
|
// @grant GM_getValue
|
|
// @grant GM_setValue
|
|
// @grant GM_registerMenuCommand
|
|
// @grant GM_addStyle
|
|
// @updateURL https://git.ponywave.de/Akamaru/Userscripts/raw/branch/master/serienfans-releasegroup-filter.user.js
|
|
// @downloadURL https://git.ponywave.de/Akamaru/Userscripts/raw/branch/master/serienfans-releasegroup-filter.user.js
|
|
// @run-at document-end
|
|
// ==/UserScript==
|
|
|
|
(function() {
|
|
'use strict';
|
|
|
|
// CSS für Block-Button und Modal
|
|
GM_addStyle(`
|
|
.block-group-btn {
|
|
display: inline;
|
|
margin-left: 5px;
|
|
background: none;
|
|
border: none;
|
|
cursor: pointer;
|
|
font-size: 14px;
|
|
padding: 0;
|
|
line-height: 1;
|
|
width: auto;
|
|
min-width: 0;
|
|
vertical-align: middle;
|
|
}
|
|
|
|
#blacklist-modal {
|
|
display: none;
|
|
position: fixed;
|
|
z-index: 10000;
|
|
left: 0;
|
|
top: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: rgba(0,0,0,0.6);
|
|
animation: fadeIn 0.2s;
|
|
}
|
|
|
|
@keyframes fadeIn {
|
|
from { opacity: 0; }
|
|
to { opacity: 1; }
|
|
}
|
|
|
|
#blacklist-modal-content {
|
|
background-color: #1a1a1a;
|
|
margin: 5% auto;
|
|
padding: 30px;
|
|
border: 1px solid #333;
|
|
border-radius: 8px;
|
|
width: 90%;
|
|
max-width: 600px;
|
|
box-shadow: 0 4px 20px rgba(0,0,0,0.5);
|
|
color: #fff;
|
|
}
|
|
|
|
#blacklist-modal h2 {
|
|
margin-top: 0;
|
|
color: #fff;
|
|
font-size: 24px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
#blacklist-items {
|
|
max-height: 400px;
|
|
overflow-y: auto;
|
|
margin: 20px 0;
|
|
background: #2a2a2a;
|
|
border-radius: 4px;
|
|
padding: 10px;
|
|
}
|
|
|
|
.blacklist-item {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 10px;
|
|
margin: 5px 0;
|
|
background: #333;
|
|
border-radius: 4px;
|
|
transition: background 0.2s;
|
|
}
|
|
|
|
.blacklist-item:hover {
|
|
background: #3a3a3a;
|
|
}
|
|
|
|
.blacklist-item-name {
|
|
flex-grow: 1;
|
|
font-size: 16px;
|
|
}
|
|
|
|
.blacklist-item-remove {
|
|
background: #d32f2f;
|
|
color: white;
|
|
border: none;
|
|
padding: 5px 12px;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 14px;
|
|
transition: background 0.2s;
|
|
}
|
|
|
|
.blacklist-item-remove:hover {
|
|
background: #b71c1c;
|
|
}
|
|
|
|
#blacklist-add-container {
|
|
display: flex;
|
|
gap: 10px;
|
|
margin: 20px 0;
|
|
}
|
|
|
|
#blacklist-add-input {
|
|
flex-grow: 1;
|
|
padding: 10px;
|
|
border: 1px solid #444;
|
|
border-radius: 4px;
|
|
background: #2a2a2a;
|
|
color: #fff;
|
|
font-size: 14px;
|
|
}
|
|
|
|
#blacklist-add-input:focus {
|
|
outline: none;
|
|
border-color: #666;
|
|
}
|
|
|
|
#blacklist-add-btn, #blacklist-close-btn {
|
|
padding: 10px 20px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
transition: background 0.2s;
|
|
}
|
|
|
|
#blacklist-add-btn {
|
|
background: #4caf50;
|
|
color: white;
|
|
}
|
|
|
|
#blacklist-add-btn:hover {
|
|
background: #45a049;
|
|
}
|
|
|
|
#blacklist-close-btn {
|
|
background: #666;
|
|
color: white;
|
|
width: 100%;
|
|
margin-top: 10px;
|
|
}
|
|
|
|
#blacklist-close-btn:hover {
|
|
background: #777;
|
|
}
|
|
|
|
.blacklist-empty {
|
|
text-align: center;
|
|
padding: 30px;
|
|
color: #888;
|
|
font-style: italic;
|
|
}
|
|
|
|
#blacklist-menu-btn {
|
|
cursor: pointer;
|
|
transition: opacity 0.2s;
|
|
}
|
|
|
|
#blacklist-menu-btn:hover {
|
|
opacity: 0.8;
|
|
}
|
|
`);
|
|
|
|
// Standard-Blacklist (kann über das Menü bearbeitet werden)
|
|
const defaultBlacklist = [];
|
|
|
|
// Lade die Blacklist aus den gespeicherten Einstellungen
|
|
let blacklist = GM_getValue('releasegroup_blacklist', defaultBlacklist);
|
|
|
|
// Funktion zum Ausblenden von Einträgen
|
|
function filterReleases() {
|
|
const entries = document.querySelectorAll('.entry');
|
|
|
|
entries.forEach(entry => {
|
|
const releasegroupSpan = entry.querySelector('.audiotag:has(small:contains("Releasegruppe:"))');
|
|
|
|
if (releasegroupSpan) {
|
|
const releasegroupText = releasegroupSpan.textContent.trim();
|
|
const releasegroup = releasegroupText.replace('Releasegruppe:', '').trim();
|
|
|
|
if (blacklist.some(blocked => blocked.toLowerCase() === releasegroup.toLowerCase())) {
|
|
// Blende den Entry-Container und das dazugehörige Checkbox aus
|
|
entry.style.display = 'none';
|
|
const checkbox = entry.previousElementSibling;
|
|
if (checkbox && checkbox.classList.contains('show_nfo')) {
|
|
checkbox.style.display = 'none';
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// Funktion zum Blocken einer Releasegruppe
|
|
function blockReleasegroup(releasegroup) {
|
|
if (!blacklist.some(blocked => blocked.toLowerCase() === releasegroup.toLowerCase())) {
|
|
blacklist.push(releasegroup);
|
|
GM_setValue('releasegroup_blacklist', blacklist);
|
|
location.reload();
|
|
}
|
|
}
|
|
|
|
// Alternative querySelector-Methode (robuster)
|
|
function filterReleasesAlternative() {
|
|
const entries = document.querySelectorAll('.entry');
|
|
|
|
entries.forEach(entry => {
|
|
let releasegroup = null;
|
|
|
|
// Methode 1: Serienfans/Filmfans - <span class="grouptag">
|
|
const grouptag = entry.querySelector('.grouptag');
|
|
if (grouptag) {
|
|
releasegroup = grouptag.textContent.trim();
|
|
} else {
|
|
// Methode 2: Ältere Struktur - .audiotag mit "Releasegruppe:"
|
|
const audiotags = entry.querySelectorAll('.audiotag');
|
|
audiotags.forEach(tag => {
|
|
const small = tag.querySelector('small');
|
|
if (small && small.textContent.includes('Releasegruppe:')) {
|
|
releasegroup = tag.textContent.replace('Releasegruppe:', '').trim();
|
|
}
|
|
});
|
|
}
|
|
|
|
// Prüfe ob Releasegruppe geblockt werden soll
|
|
if (releasegroup && blacklist.some(blocked => blocked.toLowerCase() === releasegroup.toLowerCase())) {
|
|
entry.style.display = 'none';
|
|
const checkbox = entry.previousElementSibling;
|
|
if (checkbox && checkbox.tagName === 'INPUT') {
|
|
checkbox.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// Füge Block-Button hinzu, wenn noch nicht vorhanden
|
|
if (releasegroup && !entry.querySelector('.block-group-btn')) {
|
|
const h3 = entry.querySelector('h3');
|
|
if (h3) {
|
|
const blockBtn = document.createElement('button');
|
|
blockBtn.textContent = '🚫';
|
|
blockBtn.className = 'block-group-btn';
|
|
blockBtn.title = `Releasegruppe "${releasegroup}" blocken`;
|
|
blockBtn.onclick = (e) => {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
if (confirm(`Releasegruppe "${releasegroup}" zur Blacklist hinzufügen?`)) {
|
|
blockReleasegroup(releasegroup);
|
|
}
|
|
};
|
|
h3.appendChild(blockBtn);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// Funktion zum Erstellen des Modal-Fensters
|
|
function createBlacklistModal() {
|
|
const modal = document.createElement('div');
|
|
modal.id = 'blacklist-modal';
|
|
modal.innerHTML = `
|
|
<div id="blacklist-modal-content">
|
|
<h2>🚫 Releasegruppen-Filter</h2>
|
|
<div id="blacklist-add-container">
|
|
<input type="text" id="blacklist-add-input" placeholder="Releasegruppe hinzufügen (z.B. WvF, 4SF, WAYNE)">
|
|
<button id="blacklist-add-btn">Hinzufügen</button>
|
|
</div>
|
|
<div id="blacklist-items"></div>
|
|
<button id="blacklist-close-btn">Schließen</button>
|
|
</div>
|
|
`;
|
|
document.body.appendChild(modal);
|
|
|
|
// Event Listeners
|
|
modal.addEventListener('click', (e) => {
|
|
if (e.target === modal) {
|
|
closeModal();
|
|
}
|
|
});
|
|
|
|
document.getElementById('blacklist-close-btn').addEventListener('click', closeModal);
|
|
document.getElementById('blacklist-add-btn').addEventListener('click', addToBlacklist);
|
|
document.getElementById('blacklist-add-input').addEventListener('keypress', (e) => {
|
|
if (e.key === 'Enter') {
|
|
addToBlacklist();
|
|
}
|
|
});
|
|
|
|
updateBlacklistDisplay();
|
|
}
|
|
|
|
// Funktion zum Aktualisieren der Blacklist-Anzeige
|
|
function updateBlacklistDisplay() {
|
|
const container = document.getElementById('blacklist-items');
|
|
if (!container) return;
|
|
|
|
if (blacklist.length === 0) {
|
|
container.innerHTML = '<div class="blacklist-empty">Keine Releasegruppen geblockt</div>';
|
|
return;
|
|
}
|
|
|
|
container.innerHTML = blacklist.map(group => `
|
|
<div class="blacklist-item">
|
|
<span class="blacklist-item-name">${group}</span>
|
|
<button class="blacklist-item-remove" data-group="${group}">Entfernen</button>
|
|
</div>
|
|
`).join('');
|
|
|
|
// Event Listeners für Remove-Buttons
|
|
container.querySelectorAll('.blacklist-item-remove').forEach(btn => {
|
|
btn.addEventListener('click', (e) => {
|
|
const group = e.target.getAttribute('data-group');
|
|
removeFromBlacklist(group);
|
|
});
|
|
});
|
|
}
|
|
|
|
// Funktion zum Hinzufügen einer Releasegruppe
|
|
function addToBlacklist() {
|
|
const input = document.getElementById('blacklist-add-input');
|
|
const group = input.value.trim();
|
|
|
|
if (group === '') return;
|
|
|
|
if (blacklist.some(blocked => blocked.toLowerCase() === group.toLowerCase())) {
|
|
alert(`"${group}" ist bereits in der Blacklist!`);
|
|
return;
|
|
}
|
|
|
|
blacklist.push(group);
|
|
GM_setValue('releasegroup_blacklist', blacklist);
|
|
input.value = '';
|
|
updateBlacklistDisplay();
|
|
filterReleasesAlternative();
|
|
}
|
|
|
|
// Funktion zum Entfernen einer Releasegruppe
|
|
function removeFromBlacklist(group) {
|
|
blacklist = blacklist.filter(item => item !== group);
|
|
GM_setValue('releasegroup_blacklist', blacklist);
|
|
updateBlacklistDisplay();
|
|
location.reload();
|
|
}
|
|
|
|
// Funktion zum Öffnen des Modals
|
|
function openModal() {
|
|
const modal = document.getElementById('blacklist-modal');
|
|
if (modal) {
|
|
modal.style.display = 'block';
|
|
updateBlacklistDisplay();
|
|
document.getElementById('blacklist-add-input').focus();
|
|
}
|
|
}
|
|
|
|
// Funktion zum Schließen des Modals
|
|
function closeModal() {
|
|
const modal = document.getElementById('blacklist-modal');
|
|
if (modal) {
|
|
modal.style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// Funktion zum Hinzufügen des Buttons im Header
|
|
function addHeaderButton() {
|
|
const menu = document.getElementById('menu');
|
|
if (!menu) return;
|
|
|
|
const menuBtn = document.createElement('a');
|
|
menuBtn.id = 'blacklist-menu-btn';
|
|
menuBtn.textContent = '🚫 Filter';
|
|
menuBtn.addEventListener('click', (e) => {
|
|
e.preventDefault();
|
|
openModal();
|
|
});
|
|
|
|
// Füge Button vor dem Settings-Link ein
|
|
const settingsLink = menu.querySelector('.settings');
|
|
if (settingsLink) {
|
|
menu.insertBefore(menuBtn, settingsLink);
|
|
} else {
|
|
menu.appendChild(menuBtn);
|
|
}
|
|
}
|
|
|
|
// Registriere Menübefehl (als Fallback)
|
|
GM_registerMenuCommand('Releasegruppen-Filter bearbeiten', openModal);
|
|
|
|
// Initialisierung
|
|
addHeaderButton();
|
|
createBlacklistModal();
|
|
filterReleasesAlternative();
|
|
|
|
// Beobachte Änderungen (falls Inhalte dynamisch nachgeladen werden)
|
|
const observer = new MutationObserver(() => {
|
|
filterReleasesAlternative();
|
|
});
|
|
|
|
const listContainer = document.getElementById('list');
|
|
if (listContainer) {
|
|
observer.observe(listContainer, { childList: true, subtree: true });
|
|
}
|
|
})();
|