1
0
ANTI-BS/content.js
lordlogo2002 4bbbcd8040 Add content script and popup for channel whitelist management
- Implement content script to identify member-only videos on YouTube
- Create popup interface for managing a channel whitelist
- Add necessary icons and manifest configuration
2026-01-19 18:55:43 +01:00

58 lines
1.5 KiB
JavaScript

console.log("[MemberFilter] content script loaded");
const seen = new WeakSet();
function findMemberVideos(root = document) {
const badges = root.querySelectorAll(
'badge-shape, ytd-badge-supported-renderer'
);
badges.forEach(badge => {
if (!badge.textContent?.includes("Nur für Kanalmitglieder")) return;
const video =
badge.closest("ytd-rich-item-renderer, ytd-video-renderer, ytd-grid-video-renderer");
if (!video) return;
if (seen.has(video)) return;
seen.add(video);
// ---- extract data ----
const titleEl = video.querySelector("#video-title");
const channelEl =
video.querySelector("ytd-channel-name a") ||
video.querySelector(".ytd-channel-name a");
const title = titleEl?.textContent?.trim() ?? "(no title)";
const url = titleEl?.href ?? "(no url)";
const channel = channelEl?.textContent?.trim() ?? "(no channel)";
console.group("[MemberFilter] Member-only video found");
console.log("Title :", title);
console.log("Channel:", channel);
console.log("URL :", url);
console.log("Node :", video);
console.groupEnd();
});
}
// Initial scan
findMemberVideos();
// Observe dynamic changes
const observer = new MutationObserver(mutations => {
for (const m of mutations) {
for (const node of m.addedNodes) {
if (!(node instanceof HTMLElement)) continue;
findMemberVideos(node);
}
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});