// ==UserScript== // @name Twitch – All in One // @author Knoks // @namespace https://github.com/local/twitch-theater-mode // @version 1.8.7 // @updateURL https://raw.githubusercontent.com/Knoks1111/Tampermonkey-Script/main/Twitch-All-in-One.user.js // @downloadURL https://raw.githubusercontent.com/Knoks1111/Tampermonkey-Script/main/Twitch-All-in-One.user.js // @description Mode Studio automatique, volume à la molette, anti-spoil et masquage personnalisable des éléments Twitch. // @icon https://www.twitch.tv/favicon.ico // @match https://www.twitch.tv/* // @match https://twitch.tv/* // @grant GM_setValue // @grant GM_getValue // @run-at document-start // ==/UserScript== (function () { 'use strict'; const THEATER_SETTING_KEY = 'ttv_feature_theater_auto_v1'; const isTheaterAutoEnabled = () => GM_getValue(THEATER_SETTING_KEY, true) !== false; let scriptActivated = false; let userDeactivated = false; let watchingBtn = null; let reactivateTimer = null; const isStreamPage = () => { const path = location.pathname; const excluded = ['', '/', '/directory', '/following', '/browse', '/prime', '/turbo']; return /^\/[^/]+\/?$/.test(path) && !excluded.includes(path.replace(/\/$/, '')); }; function getBtn() { // Twitch duplique ce bouton : ne garder que sa version visible. const candidates = [...document.querySelectorAll('button[aria-label]')].filter(btn => { const l = btn.getAttribute('aria-label').toLowerCase(); return l.includes('studio') || l.includes('theater') || l.includes('theatre'); }); const visible = candidates.find(btn => btn.offsetParent !== null); return visible || candidates[0] || null; } const isActive = () => { const btn = getBtn(); if (!btn) return false; return !!btn.getAttribute('aria-label').toLowerCase().match(/quitter|exit/); }; function scheduleReactivation() { clearTimeout(reactivateTimer); reactivateTimer = setTimeout(() => { if (!isTheaterAutoEnabled()) return; userDeactivated = false; if (isStreamPage() && !isActive()) { const btn = getBtn(); if (btn) btn.click(); } }, 20_000); } function attachListener(btn) { if (watchingBtn === btn) return; watchingBtn = btn; btn.addEventListener('click', (e) => { if (!e.isTrusted) return; const wasActive = isActive(); if (wasActive) { userDeactivated = true; scheduleReactivation(); } else { userDeactivated = false; clearTimeout(reactivateTimer); } }, { capture: true }); } function activate() { if (!isTheaterAutoEnabled() || !isStreamPage() || scriptActivated || userDeactivated || isActive()) return; const btn = getBtn(); if (!btn) return; attachListener(btn); btn.click(); scriptActivated = true; const guard = setInterval(() => { if (!isTheaterAutoEnabled() || userDeactivated) { clearInterval(guard); return; } if (!isActive()) { const b = getBtn(); if (b) b.click(); clearInterval(guard); } }, 250); setTimeout(() => clearInterval(guard), 5000); } function waitForPlaying() { if (!isTheaterAutoEnabled() || !isStreamPage()) return; const video = document.querySelector('video'); if (video) { // Bascule dès que le bouton Studio visible est prêt. const btn = getBtn(); if (btn && btn.offsetParent !== null) { activate(); return; } if (!video.paused) { activate(); return; } video.addEventListener('playing', activate, { once: true }); } } let scheduled = false; new MutationObserver(() => { if (!isTheaterAutoEnabled() || scriptActivated || userDeactivated || scheduled) return; const video = document.querySelector('video'); if (!video) return; scheduled = true; setTimeout(() => { scheduled = false; waitForPlaying(); }, 25); }).observe(document.documentElement, { childList: true, subtree: true }); let lastUrl = location.href; function onUrlChange() { if (location.href === lastUrl) return; lastUrl = location.href; scriptActivated = false; userDeactivated = false; watchingBtn = null; clearTimeout(reactivateTimer); setTimeout(activate, 100); } for (const m of ['pushState', 'replaceState']) { const orig = history[m].bind(history); history[m] = (...a) => { orig(...a); onUrlChange(); }; } window.addEventListener('popstate', onUrlChange); window.addEventListener('tsb-setting-change', event => { if (event.detail?.key !== THEATER_SETTING_KEY) return; clearTimeout(reactivateTimer); if (event.detail.value) { userDeactivated = false; scriptActivated = false; setTimeout(activate, 25); } else { userDeactivated = true; } }); waitForPlaying(); })(); (function () { 'use strict'; const EXTENSIONS_SETTING_KEY = 'ttv_feature_extensions_block_v1'; const CSS = ` [class*="extensions-video-overlay-size-container"], [class*="extensions-dock__dock"], [class*="extensions-dock-card"], [class*="extensions-popover"], [class*="extensions-notifications"], [class*="extensions-info-balloon"] { display: none !important; pointer-events: none !important; } `; const style = document.createElement('style'); style.id = 'twitch-disable-extensions-css'; const applySetting = () => { style.textContent = GM_getValue(EXTENSIONS_SETTING_KEY, true) !== false ? CSS : ''; }; applySetting(); (document.head || document.documentElement).appendChild(style); window.addEventListener('tsb-setting-change', event => { if (event.detail?.key === EXTENSIONS_SETTING_KEY) applySetting(); }); })(); (function () { 'use strict'; let watchedVideo = null; function syncVolume(video) { localStorage.setItem('volume', String(video.volume)); localStorage.setItem('video-muted', JSON.stringify({ default: video.muted })); } function attach(video) { if (watchedVideo === video) return; watchedVideo = video; video.addEventListener('volumechange', () => syncVolume(video)); // Attendre l'initialisation Twitch évite d'enregistrer son volume temporaire à 100 %. } function findAndAttach() { const video = document.querySelector('video'); if (video && video !== watchedVideo) attach(video); } new MutationObserver(findAndAttach) .observe(document.documentElement, { childList: true, subtree: true }); findAndAttach(); })(); (function () { 'use strict'; const VOLUME_WHEEL_SETTING_KEY = 'ttv_feature_volume_wheel_v1'; const STEP = 0.01; let osd = null, hideTimer = null; function ensureOsd() { if (osd) return osd; if (!document.getElementById('ttv-liquid-glass-defs')) { const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); svg.id = 'ttv-liquid-glass-defs'; svg.style.cssText = 'position:absolute;width:0;height:0;overflow:hidden;'; svg.innerHTML = ` `; document.body.appendChild(svg); } osd = document.createElement('div'); osd.id = 'ttv-volume-osd'; osd.innerHTML = `
100%
`; document.body.appendChild(osd); const style = document.createElement('style'); style.textContent = ` #ttv-volume-osd { position: fixed; z-index: 2147483647; pointer-events: none; display: flex; align-items: center; gap: 10px; background: rgba(20, 20, 24, .2); backdrop-filter: url(#ttv-liquid-glass-filter) saturate(160%) brightness(.9); color: #fff; font-family: Inter, Roobert, "Helvetica Neue", Arial, sans-serif; border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px; padding: 9px 16px 9px 12px; opacity: 0; transform: translate(-50%, 6px) scale(.96); transition: opacity .15s ease, transform .15s ease; box-shadow: 0 8px 28px rgba(0, 0, 0, .4), inset 0 1px 1px rgba(255, 255, 255, .4), inset 0 -6px 10px -6px rgba(255, 255, 255, .15), inset 0 0 0 1px rgba(255, 255, 255, .04); position: fixed; overflow: hidden; } #ttv-volume-osd .ttv-volume-osd__sheen { position: absolute; inset: 0; border-radius: inherit; background: radial-gradient(120% 80% at 30% -20%, rgba(255, 255, 255, .55) 0%, rgba(255, 255, 255, 0) 55%); mix-blend-mode: overlay; pointer-events: none; } #ttv-volume-osd.ttv-visible { opacity: 1; transform: translate(-50%, 0) scale(1); } #ttv-volume-osd .ttv-volume-osd__icon { width: 18px; height: 18px; flex-shrink: 0; stroke: #efeff1; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; position: relative; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5)); } #ttv-volume-osd .ttv-volume-osd__track { width: 84px; height: 4px; background: rgba(255, 255, 255, .2); border-radius: 2px; overflow: hidden; position: relative; } #ttv-volume-osd .ttv-volume-osd__fill { height: 100%; background: #9147ff; width: 0%; transition: width .1s ease; border-radius: 2px; } #ttv-volume-osd .ttv-volume-osd__pct { font-size: 12px; font-weight: 600; letter-spacing: .2px; min-width: 30px; text-align: right; color: #efeff1; position: relative; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); } `; document.head.appendChild(style); return osd; } const ICON_MUTED = ''; const ICON_LOW = ''; const ICON_HIGH = ''; function showOsd(video) { const el = ensureOsd(); const rect = video.getBoundingClientRect(); el.style.left = (rect.left + rect.width / 2) + 'px'; el.style.top = (rect.top + rect.height * 0.86) + 'px'; const pct = video.muted ? 0 : Math.round(video.volume * 100); el.querySelector('.ttv-volume-osd__pct').textContent = pct + '%'; el.querySelector('.ttv-volume-osd__fill').style.width = pct + '%'; el.querySelector('.ttv-volume-osd__icon').innerHTML = pct === 0 ? ICON_MUTED : pct < 50 ? ICON_LOW : ICON_HIGH; el.classList.add('ttv-visible'); clearTimeout(hideTimer); hideTimer = setTimeout(() => el.classList.remove('ttv-visible'), 900); } function persistVolume(video) { localStorage.setItem('volume', String(video.volume)); localStorage.setItem('video-muted', JSON.stringify({ default: video.muted })); } // L'événement input synchronise le slider React natif avec le volume vidéo. function setNativeValue(el, value) { const setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set; setter.call(el, value); el.dispatchEvent(new Event('input', { bubbles: true })); } function syncNativeSlider(vol) { document.querySelectorAll('input.tw-range[type="range"]').forEach(slider => { if (slider.min === '0' && slider.max === '1') { setNativeValue(slider, String(vol)); } }); } function isPointInVideo(video, x, y) { if (video.closest('[data-a-target="front-page-carousel"]') && GM_getValue('tsb_feature_featured_carousel_v1', true) !== false) return false; if (getComputedStyle(video).visibility !== 'visible') return false; const r = video.getBoundingClientRect(); return r.width > 0 && r.height > 0 && x >= r.left && x <= r.right && y >= r.top && y <= r.bottom; } // La vidéo étant recouverte, détecter la molette avec les coordonnées du curseur. document.addEventListener('wheel', (e) => { if (GM_getValue(VOLUME_WHEEL_SETTING_KEY, true) === false) return; const video = [...document.querySelectorAll('video')] .find(candidate => isPointInVideo(candidate, e.clientX, e.clientY)); if (!video) return; e.preventDefault(); e.stopPropagation(); let vol = video.volume; if (e.deltaY < 0) vol = Math.min(1, vol + STEP); else vol = Math.max(0, vol - STEP); vol = Math.round(vol * 100) / 100; video.volume = vol; video.muted = vol === 0; persistVolume(video); syncNativeSlider(vol); showOsd(video); }, { passive: false, capture: true }); })(); (function () { 'use strict'; const KEY_OLD = 'tsb_v4', KEY = 'tsb_v5'; const KEY_TITLE_KEYWORDS = 'tsb_title_keywords_v1'; const SETTING_KEYS = { antiSpoil: 'tsb_feature_anti_spoil_v1', titleKeywords: 'tsb_feature_title_keywords_v1', openWarning: 'tsb_feature_open_warning_v1', revealButtons: 'tsb_feature_reveal_buttons_v1', theater: 'ttv_feature_theater_auto_v1', extensions: 'ttv_feature_extensions_block_v1', volumeWheel: 'ttv_feature_volume_wheel_v1', continueWatching: 'tsb_feature_continue_watching_v1', featuredCarousel: 'tsb_feature_featured_carousel_v1', hidePinnedChat: 'tsb_feature_hide_pinned_chat_v1', hideDropHighlights: 'tsb_feature_hide_drop_highlights_v1', hideHypeTrain: 'tsb_feature_hide_hype_train_v1', hideChatLeaderboard: 'tsb_feature_hide_clip_leaderboard_v1', hideSharedChat: 'tsb_feature_hide_shared_chat_v1', }; const isSettingEnabled = key => GM_getValue(key, true) !== false; const saveSetting = (key, value) => { const enabled = !!value; GM_setValue(key, enabled); window.dispatchEvent(new CustomEvent('tsb-setting-change', { detail: { key, value: enabled } })); }; const homeContentStyle = document.createElement('style'); homeContentStyle.id = 'tsb-home-content-style'; const updateHomeContentStyle = () => { let css = ''; if (isSettingEnabled(SETTING_KEYS.continueWatching)) { const header = 'header:has(> div > h3[data-a-target="followed-videos-continue-watching-header"])'; // Dans Suivis, le parent contient aussi les autres rangées. css += `div:has(> ${header}) { position: relative !important; } ${header}, ${header} + .tw-tower + .show-more__move-up { display: none !important; } ${header} + .tw-tower { position: absolute !important; top: 0 !important; left: 0 !important; right: 0 !important; visibility: hidden !important; opacity: 0 !important; pointer-events: none !important; z-index: -1 !important; }`; } if (isSettingEnabled(SETTING_KEYS.featuredCarousel)) { css += '[data-a-target="front-page-carousel"] { position: absolute !important; top: 0 !important; left: 0 !important; right: 0 !important; visibility: hidden !important; opacity: 0 !important; pointer-events: none !important; z-index: -1 !important; }'; } homeContentStyle.textContent = css; }; updateHomeContentStyle(); (document.head || document.documentElement).appendChild(homeContentStyle); window.addEventListener('tsb-setting-change', event => { if ([SETTING_KEYS.continueWatching, SETTING_KEYS.featuredCarousel].includes(event.detail?.key)) { updateHomeContentStyle(); } }); const chatEventStyle = document.createElement('style'); chatEventStyle.id = 'tsb-chat-event-style'; let pinnedChatTemporarilyRevealed = false; const updateChatEventStyle = () => { let css = '.community-highlight-stack__backlog-card:empty { display: none !important; }'; if (isSettingEnabled(SETTING_KEYS.hidePinnedChat) && !pinnedChatTemporarilyRevealed) { css += '.community-highlight-stack__card .tw-transition:has(.pinned-chat__highlight-card) { display: none !important; }'; } if (isSettingEnabled(SETTING_KEYS.hidePinnedChat)) { css += '.community-highlight-stack__card .pinned-chat__highlight-card button[aria-label="Hide for yourself"] { display: none !important; }'; } if (isSettingEnabled(SETTING_KEYS.hideDropHighlights)) { css += '.community-highlight-stack__card .tw-transition:has([class*="dropsHighlight--"]) { display: none !important; }'; } if (isSettingEnabled(SETTING_KEYS.hideHypeTrain)) { css += '.community-highlight-stack__card .tw-transition:has([class*="hype-train" i]), .community-highlight-stack__card .tw-transition:has([class*="hypetrain" i]), .community-highlight-stack__card .tw-transition:has([data-a-target*="hype-train" i]), .community-highlight-stack__card .tw-transition:has([data-a-target*="hypetrain" i]), [class*="hype-train" i], [class*="hypetrain" i], [data-a-target*="hype-train" i], [data-a-target*="hypetrain" i] { display: none !important; }'; } if (isSettingEnabled(SETTING_KEYS.hideSharedChat)) { css += '.community-highlight-stack__card:has([class*="sharedChatHighlight--"]) { display: none !important; }'; } if (isSettingEnabled(SETTING_KEYS.hideChatLeaderboard)) { css += '.tw-transition:has([data-testid="leaderboard-top-three-entry"]), div:has(> div > button[aria-label="Classement précédent"]):has(> div > button[aria-label="Classement suivant"]), .community-highlight-stack__card .tw-transition:has([class*="topSupporterCollapsed__eventBadge"]), div:has(> div [class*="topSupporterCollapsed__eventBadge"]):has(> button) { display: none !important; }'; } chatEventStyle.textContent = css; }; updateChatEventStyle(); (document.head || document.documentElement).appendChild(chatEventStyle); window.addEventListener('tsb-setting-change', event => { if ([SETTING_KEYS.hidePinnedChat, SETTING_KEYS.hideDropHighlights, SETTING_KEYS.hideHypeTrain, SETTING_KEYS.hideChatLeaderboard, SETTING_KEYS.hideSharedChat].includes(event.detail?.key)) { if (event.detail?.key === SETTING_KEYS.hidePinnedChat) { if (!event.detail.value) pinnedChatTemporarilyRevealed = false; processPinnedRevealButton(); } updateChatEventStyle(); } }); let _cache = null, _titleKeywordCache = null; const temporaryReveal = new Map(); const getDB = () => { if (_cache) return _cache; try { const raw = GM_getValue(KEY, null); if (raw !== null) { _cache = JSON.parse(raw); let dirty = false; for (const e of Object.values(_cache)) { if (e.whitelist === undefined) { e.whitelist = false; dirty = true; } if (e.enabled === undefined) { e.enabled = true; dirty = true; } } if (dirty) GM_setValue(KEY, JSON.stringify(_cache)); return _cache; } const old = JSON.parse(GM_getValue(KEY_OLD, '[]')); _cache = Object.fromEntries(old.map(ch => [ch.toLowerCase(), { mode: 'always', cats: [], whitelist: false, enabled: true }])); GM_setValue(KEY, JSON.stringify(_cache)); } catch { _cache = {}; } return _cache; }; const saveDB = d => GM_setValue(KEY, JSON.stringify(_cache = d)); const isInList = ch => ch.toLowerCase() in getDB(); const getEntry = ch => getDB()[ch.toLowerCase()]; const isChannelEnabled = ch => !!getEntry(ch) && getEntry(ch).enabled !== false; const normalizeText = value => (value || '') .normalize('NFKD') .replace(/[\u0300-\u036f]/g, '') .toLowerCase() .replace(/[^\p{L}\p{N}]+/gu, ' ') .trim(); const getTitleKeywords = () => { if (_titleKeywordCache) return _titleKeywordCache; try { const saved = JSON.parse(GM_getValue(KEY_TITLE_KEYWORDS, '[]')); _titleKeywordCache = Array.isArray(saved) ? saved.filter(x => typeof x === 'string') : []; } catch { _titleKeywordCache = []; } return _titleKeywordCache; }; const saveTitleKeywords = words => GM_setValue(KEY_TITLE_KEYWORDS, JSON.stringify(_titleKeywordCache = words)); const phraseMatches = (text, phrase) => { const haystack = normalizeText(text), needle = normalizeText(phrase); return !!needle && (' ' + haystack + ' ').includes(' ' + needle + ' '); }; const titleMatchesKeyword = title => isSettingEnabled(SETTING_KEYS.titleKeywords) && getTitleKeywords().some(word => phraseMatches(title, word)); const getRevealMode = ch => temporaryReveal.get(ch.toLowerCase()) ?? null; const TITLE_WHITELIST = [ 'bonjour','bonsoir','bjr','bsr','bonne nuit','salut','slt','coucou','cc', 'hello','hi','hey','yo','salam','salem','wsh','wesh','au revoir','aurevoir', 'à bientôt','a bientot','bonne soirée','bonne journée','tchao','ciao','bye', 'à plus','a plus','aplus','à tout','a tout','bisous','bises', 'discussion','discussions','discute','discuter','discutons','discu', 'parlote','parler','parlons','papote','papoter','papotage','papotons', 'causette','causer','causons','bavardage','bavarder','blabla','bla bla', 'just chatting','parle','cause','vibe','vibes','chill','chillax', 'détente','detente','relax','tranquille','tranquilo', ]; const titleMatchesWhitelist = title => TITLE_WHITELIST.some(w => phraseMatches(title, w)); const isTitleBlurred = (ch, title, category = '') => { if (!isSettingEnabled(SETTING_KEYS.antiSpoil)) return false; if (getRevealMode(ch)) return false; if (titleMatchesKeyword(title || '')) return true; if (!isBlurred(ch, category)) return false; const entry = getEntry(ch); return !entry?.whitelist || !titleMatchesWhitelist(title || ''); }; const pendingDelete = new Map(); const CATEGORY_ALIASES = { 'just chatting': 'discussions', 'art': 'art', 'music': 'musique', 'science & technology': 'science et technologie', 'food & drink': 'nourriture et boissons', 'politics': 'politique', 'pools, hot tubs, and beaches': 'piscines, jacuzzi et plages', 'travel & outdoors': 'animaux, aquariums et zoos', 'software and game development': 'développement de logiciels et de jeux', 'makers & crafting': 'créateurs et artisanat', 'sports': 'sport', 'talk shows & podcasts': 'talk-shows et podcasts', 'special events': 'evenements speciaux', 'crypto': 'crypto', 'health & fitness': 'bien-être et santé', 'asmr': 'asmr', 'games + demos': 'games + demos', 'study and co-working': 'co-working et etudes', 'lego': 'lego et briques de construction', }; const normalizeCat = c => { const k = (c || '').toLowerCase().trim(); return CATEGORY_ALIASES[k] || k; }; const isBlurred = (ch, cat = '') => { if (!isSettingEnabled(SETTING_KEYS.antiSpoil)) return false; const k = ch.toLowerCase(); if (pendingDelete.has(k)) return false; const entry = getEntry(ch); if (!entry || entry.enabled === false) return false; const { mode, cats } = entry; const c = normalizeCat(cat); if (mode === 'always' || !c) return true; const match = cats.some(x => c.includes(x)); return mode === 'only' ? match : !match; }; const addChannel = ch => { const db = getDB(), k = ch.toLowerCase().trim(); if (!k || k in db) return false; db[k] = { mode: 'always', cats: [], whitelist: false, enabled: true }; saveDB(db); return true; }; const setChannelEnabled = (ch, enabled) => { const db = getDB(), k = ch.toLowerCase(); if (!(k in db)) return false; db[k].enabled = !!enabled; if (!enabled) temporaryReveal.delete(k); saveDB(db); return true; }; const toggleChannelProtection = ch => { if (!isInList(ch)) return addChannel(ch); return setChannelEnabled(ch, !isChannelEnabled(ch)); }; const removeChannel = ch => { const db = getDB(), k = ch.toLowerCase(); if (!(k in db)) return; delete db[k]; saveDB(db); temporaryReveal.delete(k); const cache = getAvatarCache(); if (k in cache) { delete cache[k]; saveAvatarCache(cache); } }; const setMode = (ch, mode) => { const db = getDB(), k = ch.toLowerCase(); if (!(k in db)) return; db[k].mode = mode; saveDB(db); }; const addCat = (ch, cat) => { const db = getDB(), k = ch.toLowerCase(), c = cat.toLowerCase().trim(); if (!c || !(k in db) || db[k].cats.includes(c)) return false; db[k].cats.push(c); saveDB(db); return true; }; const removeCat = (ch, cat) => { const db = getDB(), k = ch.toLowerCase(), c = cat.toLowerCase().trim(); if (!(k in db)) return; db[k].cats = db[k].cats.filter(x => x !== c); saveDB(db); }; const setWhitelist = (ch, val) => { const db = getDB(), k = ch.toLowerCase(); if (!(k in db)) return; db[k].whitelist = !!val; saveDB(db); }; const commitPendingDeletes = () => { pendingDelete.forEach((_, ch) => removeChannel(ch)); pendingDelete.clear(); }; const TWITCH_CATEGORIES = ["007 First Light","2XKO","7 Days to Die","9 Kings","A Way Out","ARC Raiders","ARK: Survival Ascended","ARK: Survival Evolved","ARKNIGHTS: ENDFIELD","ASMR","Abiotic Factor","Ace Attorney Investigations 2: Prosecutor's Gambit","Age of Empires II","Age of Empires IV","Age of Mythology","Aion","Aion 2","Airport Baggage Simulator","Alan Wake II","Albion Online","Alice: Madness Returns","Alien: Isolation","Always On","American Truck Simulator","Among Us","Animal Crossing: New Horizons","Animaux, aquariums et zoos","Anime Squad","Apex Legends","Arctic Eggs","Arena Breakout: Infinite","Arena of Valor","Arknights","Arma Reforger","Armored Warfare","Art","Assassin's Creed IV Black Flag","Assassin's Creed Valhalla","Assetto Corsa","Auto Chess","BATTLETECH","BUBSY 4D","Backrooms: Escape Together","Balatro","Baldur's Gate 3","Banjo-Kazooie","Batman: Arkham Knight","Battlefield 1","Battlefield 6","Battlefield REDSEC","Bayonetta","Bayonetta 2","BeamNG.drive","BeastLink","Beat Saber","Beat The Beat: Rhythm Paradise","Beyond: Two Souls","Bien-être et santé","BioShock Remastered","BitCraft Online","Black Desert","Black Myth: Wukong","Blades of Fire","Blasphemous II","Bloodborne","Blue Archive","Blue Prince","Blue Protocol: Star Resonance","Board Games","Borderlands 2","Borderlands 4","Borderlands: Game of the Year Enhanced","Brawl Stars","Brawlhalla","BrokenLore: UNFOLLOW","Brotato","Bubsy 3D","Bunny Guys!","Burglin' Gnomes","Business Tour","Butcher's Creek","CABAL Online","CAPTURED 2","Call of Duty","Call of Duty 4: Modern Warfare","Call of Duty: Black Ops","Call of Duty: Black Ops 4","Call of Duty: Black Ops 6","Call of Duty: Black Ops 7","Call of Duty: Black Ops II","Call of Duty: Black Ops III","Call of Duty: Mobile","Call of Duty: Modern Warfare II","Call of Duty: Modern Warfare III","Call of Duty: Warzone","Call of the Elder Gods","Capcom vs. SNK 2: Mark of the Millennium 2001","Captain of Industry","Car Mechanic Simulator 2018","Casino Simulator 2024","Castlevania: Symphony of the Night","Celeste","Chaos Zero Nightmare","Cheap Car Repair","Chess","Chorus of Carcosa","Chrono Trigger","Cinderia","Cities: Skylines","Cities: Skylines II","Clair Obscur: Expedition 33","Clash Royale","Clone Hero","Codenames","Coffee Talk: Tokyo","Conan Exiles","Conqueror's Blade","Content Warning","Contexto","Coral Island","Core Keeper","Corsair Cove","Counter-Strike","Crab Champions","Crash Bandicoot","Crash Bandicoot: The Wrath of Cortex","Crashout Crew","Creature Kitchen","Crime Scene Cleaner","Crimson Desert","Crypto","Crystal of Atlan","Créateurs et artisanat","Cube Escape: Paradox","Cult of the Lamb","Cuphead","Cure: A Hospital Simulator","Cyberpunk 2077","DARK SOULS II: Scholar of the First Sin","DARK SOULS III","DIGIMON STORY: TIME STRANGER","DJ","DJ Mole","DON'T LOOK AT GRANDMA","DOOM Eternal","DRAGON BALL GEKISHIN SQUADRA","DRAGON BALL Z: KAKAROT","DRAGON BALL: Sparking! ZERO","DRAGON QUEST MONSTERS: The Dark Prince","Dark Souls: Remastered","Dark and Darker","Darkest Dungeon II","Date Everything!","Dave the Diver","DayZ","Days Gone","Dead Space","Dead as Disco","Dead by Daylight","Deadlock","Death Stranding 2: On the Beach","Deceit 2","Deep Rock Galactic","Deep Rock Galactic: Rogue Core","Delta Force","Deltarune","Demonologist","Destiny 2","Detroit: Become Human","Devil May Cry 3: Dante's Awakening - Special Edition","Devil May Cry 5","Diablo II: Resurrected","Diablo IV","Digimon World","Diplomacy is Not an Option","Directive 8020","Discussions","Disney Dreamlight Valley","Dispatch","Divinity: Original Sin II","Dofus","Don't Starve Together","Donkey Kong Country","Donkey Kong Country 2: Diddy's Kong-Quest","Dota 2","Down with the Ship","Dragon Ball Legends","Dragon Ball: The Breakers","Dragon Quest Builders 2","Dragon Quest VI: Maboroshi no Daichi","Dragon Quest: The Journey of the Cursed King","Dragon Warrior IV","Duck Game","Dune: Awakening","Dungeons & Dragons","Dwarf Fortress","Dying Light","Dying Light: The Beast","Développement de logiciels et de jeux","EA Sports College Football 26","EA Sports FC 26","EA Sports UFC 5","ELDEN RING","ELDEN RING NIGHTREIGN","EVE Online","EarthBound","Elite: Dangerous","Emissary Zero","Empire Earth","Enshrouded","Entropia Universe","Epic Seven","Escape Simulator","Escape from Tarkov","Escape the Backrooms","Eternal Return","Euro Truck Simulator 2","EverQuest","EverQuest Legends","Everything Is Crab","Exanima","F1 25","FATAL FRAME II: Crimson Butterfly REMAKE","FIFA Mobile","FINAL FANTASY IV","FINAL FANTASY IX","FINAL FANTASY TACTICS","FINAL FANTASY VII","FINAL FANTASY VII REBIRTH","FINAL FANTASY VII REMAKE","FINAL FANTASY VIII Remastered","FINAL FANTASY X","FINAL FANTASY XI ONLINE","FINAL FANTASY XIV ONLINE","FTL: Faster Than Light","Factorio","Fall Guys","Fallout 4","Fallout 76","Fallout: A Post Nuclear Role Playing Game","Fallout: New Vegas","Far Far West","Farever","Farm Frenzy","Farming Simulator 25","Fatal Fury: City of the Wolves","Fear & Hunger 2: Termina","Fields of Mistria","Final Fantasy VI","Fire Emblem: Fuuin no Tsurugi","Fire Emblem: Radiant Dawn","Fire Emblem: Three Houses","Fishing Planet","Five Nights at Freddy's","Flyff Universe","Football Manager 26","For Honor","Forbidden Solitaire","Fortnite","Forza Horizon 5","Forza Horizon 6","Foxhole","FragPunk","Free Fire","Friday the 13th: The Game","Furi","GODDESS OF VICTORY: NIKKE","GTA: La Heist","GUILTY GEAR -STRIVE-","Gamble With Your Friends","Games + Demos","Games Done Quick","Garry's Mod","Gartic Phone","Gears 5","Gears of War 2","Gears of War 4","Gears of War: Reloaded","Genshin Impact","GeoGuessr","Geometry Dash","Ghost of Tsushima","Ghost of Yotei","Ghosts of Tabor","God of War","God of War Ragnarok","GoldenEye 007","Golf With Your Friends","Goofy Gorillas","Goose Goose Duck","Gothic II","Gran Turismo 7","Granblue Fantasy Versus: Rising","Granblue Fantasy: Relink","Grand Theft Auto IV","Grand Theft Auto V","Grand Theft Auto: San Andreas","Grand Theft Auto: Vice City","Graveyard Keeper","Gray Zone Warfare","Green Hell","Grounded","Grounded 2","Guild Wars 2","Gwent: The Witcher Card Game","HELLDIVERS 2","HITMAN World of Assassination","Hades","Hades II","Halo Infinite","Halo: Combat Evolved","Halo: The Master Chief Collection","Hamsteria!","Harold HALIBUT","Hearthstone","Heartopia","Hell Let Loose","Hell Let Loose: Vietnam","Heroes of Might & Magic: Olden Era","Heroes of Might and Magic III: The Restoration of Erathia","Heroes of Newerth Reborn","Heroes of the Storm","Hogwarts Legacy","Hollow Knight","Hollow Knight: Silksong","Home","Honkai: Star Rail","Hozy","Human: Fall Flat","Hunt Club On Stream","Hunt: Showdown 1896","Hytale","I'm Only Sleeping","ICARUS","IRL","Infinity Nikki","Into the Fire","Invincible VS","It Reaches","It Takes Two","Jackbox Party Packs","Jigsaw Puzzle","Jikkyou Pawafuru Puroyakyu 2012","Judgment","KILLER INN","Kantai Collection","Karaoke Party","Kathy Rain 2: Soothsayer","Kenshi","Kinect Sports","Kingdom Come: Deliverance","Kingdom Come: Deliverance II","Kingdom Hearts HD 1.5 + 2.5 ReMIX","Kingdom Hearts III","Kingdom Two Crowns","Kingdoms of Amalur: Reckoning","Knight Online","Knights and Bikes","KovaaK's Aim Trainer","Kukoro: Stream Chat Games","L.A. Noire","LEGO Batman: Legacy of the Dark Knight","LEGO et briques de construction","LOCKDOWN Protocol","Le Mans Ultimate","League of Legends","League of Legends: Wild Rift","Left 4 Dead 2","Legend of YMIR","Lethal Company","Liar's Bar","Librarian: Tidy Up the Arcane Library!","Lies of P","Life is Strange: Reunion","Lineage II","Little Nightmares II","Look Outside","Lost Ark","Lost and Found Co.","Lucky Tower Ultimate","LumenTale: Memories of Trey","Luna Abyss","Lunacid","LurkBait Twitch Fishing","MARVEL Contest of Champions","MARVEL SNAP","MARVEL Strike Force","MARVEL War of Heroes","MIMESIS","MIR 4","MLB The Show 18","MLB The Show 26","MONSTER HUNTER STORIES 3: TWISTED REFLECTION","MOTHER 3","MOUSE: P.I. For Hire","MU Online","Madden NFL 26","Maestro","Mafia: The Old Country","Magic Chess: Go Go","Magic: The Gathering","Magical Delicacy","Mahjong Soul","MapleStory","MapleStory Worlds","Maquettes et figurines","Marathon","Marbles on Stream","Mario Kart 8 Deluxe","Mario Kart World","Mario Party 3","Marvel Heroes","Marvel Rivals","Marvel vs. Capcom 2: New Age of Heroes","Marvel's Spider-Man","Marvel's Spider-Man 2","Mass Effect Legendary Edition","Mayor May Knott","Mazebound: Hunt, Gather, Run!","MechWarrior 4: Mercenaries","MechWarrior 5: Mercenaries","Mecha BREAK","Mega Man 2","Mega Man Xtreme","Megabonk","Melty Blood Actress Again Current Code","Metal Gear Rising: Revengeance","Metin2","Mewgenics","Microsoft Flight Simulator 2024","Middle-earth: Shadow of Mordor","Middle-earth: Shadow of War","Midnight Special","Mina the Hollower","Minecraft","Mir Korabley","Mir Tankov","Mobile Legends: Bang Bang","Mongil: Star Dive","Monster Hunter Rise","Monster Hunter Wilds","Monster Hunter: World","Moonsigil Atlas","Mortal Kombat 1","Mortal Kombat 11","Mouseward","Mu: Dark Epoch","Muffins on Stream","Muse Dash","Musique","My Hero Ultra Rumble","My Little Puppy","My Summer Car","NARAKA: BLADEPOINT","NBA 2K26","NEBULOUS: Fleet Command","NHL 26","NO BACKUP","NTE: Neverness to Everness","Need for Speed: Heat","Need for Speed: Underground","New World: Aeternum","NieR: Automata","Nine Sols","Ninja Gaiden Black","No Man's Sky","Nourriture et boissons","Oaken Tower","Octopath Traveler","Old School RuneScape","Once Human","Out of the Park Baseball 27","Outbound","Outer Wilds","Overwatch","PAYDAY 3","PEAK","PERSONA3 RELOAD","PGA TOUR 2K25","PICO PARK 2","PRAGMATA","PUBG MOBILE","PUBG: BATTLEGROUNDS","Pacific Drive","Pain Pain Go Away!","Palia","Palworld","Paralives","Party Animals","Path of Exile 2","Path of Titans","Pawafuru Puroyakyu 2024-2025","Perfect World","Persona 4 Golden","Persona 5 Royal","Phantasy Star Online 2 New Genesis","Phasmophobia","Pinball","Piscines, jacuzzi et plages","Placid Plastic Duck Simulator","Planet Crafter","PlateUp!","Point Blank","PokeMMO","Pokemon","Pokemon Black Version 2","Pokemon Black/White","Pokemon Black/White Version 2","Pokemon Brilliant Diamond/Shining Pearl","Pokemon Champions","Pokemon Community Game","Pokemon Emerald Version","Pokemon FireRed/LeafGreen","Pokemon GO","Pokemon Legends: Z-A","Pokemon Pokopia","Pokemon Red/Blue","Pokemon Scarlet/Violet","Pokemon Stadium","Pokemon Sword/Shield","Pokemon Trading Card Game","Pokemon Trading Card Game Live","Pokemon Trading Card Game Pocket","Pokemon UNITE","Politique","Poppy Playtime","Poppy Playtime: Chapter 4 - Safe Haven","Portal 2","PowerWash Simulator","PowerWash Simulator 2","Pratfall","Predecessor","Prime World","Project Zomboid","Psalm 2","Pummel Party","QSMP","R.E.P.O.","R2 Online: Reign of Revolution","REMATCH","REPLACED","RESIDENT EVIL 7 biohazard","RESIDENT EVIL: requiem","RISK: The Game of Global Domination","ROBLOX","RV There Yet?","Racing Master","Raft","Ragnarok Online","Raid: Shadow Legends","Rainbow Six Siege","RavenQuest","Ravenswatch","Ready or Not","Realm of Ink","Red Dead Redemption","Red Dead Redemption II","Resident Evil","Resident Evil 2","Resident Evil 3","Resident Evil 4","Resident Evil 5","Resident Evil Village","Restore Your Island","Retail Hell","Retro","Retro Rewind: Video Store Simulator","Rewind or Die","RimWorld","Rise Online","Rise of the Tomb Raider","Risk of Rain 2","Road to Empress","Rocket League","Rogue Company","Romancing SaGa 2: Revenge of the Seven","Romestead","Rune Factory: Guardians of Azuma","RuneScape","RuneScape: Dragonwilds","Russian Fishing 4","Rust","S.T.A.L.K.E.R. G.A.M.M.A.","SAROS","SCUM","SEKIRO: SHADOWS DIE TWICE","SILENT HILL f","SMITE","SMITE 2","SOUND VOLTEX EXCEED GEAR","SPLITGATE: Arena Reloaded","STALCRAFT: X","Satisfactory","Schedule I","Science et technologie","Scritchy Scratchy","Sea of Thieves","Seclusion","Shadowverse: Worlds Beyond","Shakes and Fidget","Shenmue II","Sherlock Holmes: Crimes & Punishments","Shin Megami Tensei","Sid Meier's Civilization V","Sid Meier's Civilization VI","Sid Meier's Civilization VII","Silent Hill 2","Sky: Children of the Light","Slay the Spire II","Sledding Game","Sleeping Dogs","Slime Rancher","SnowRunner","Sonic Adventure DX: Director's Cut","Sonic Mania","Sonic Racing: CrossWorlds","Sonic and the Black Knight","Sons of the Forest","Soulframe","Species: Unknown","Splatoon 3","Split Fiction","SpongeBob SquarePants: Battle for Bikini Bottom","Sport","Standoff 2","Star Citizen","Star Trek Fleet Command","Star Wars Battlefront II","Star Wars Jedi: Survivor","Star Wars: The Old Republic","StarCraft II","StarWard","Stardew Valley","Starfield","Starminer","Starship EVO","Stellar Blade","Stellaris","Stray","Street Fighter 6","Strinova","Subnautica","Subnautica 2","Subnautica: Below Zero","Summoners War: Sky Arena","Super Battle Golf","Super Castlevania IV","Super Mario 64","Super Mario Maker 2","Super Mario Odyssey","Super Mario Party Jamboree","Super Mario RPG","Super Mario Sunshine","Super Mario World","Super Metroid","Super Smash Bros. Melee","Super Smash Bros. Ultimate","Supermarket Simulator","Supermarket Together","TBH: Task Bar Hero","TCG Card Shop Simulator","TEKKEN 8","THE FINALS","THE KING OF FIGHTERS XV","TV Station Manager","Tales Runner","Talk-shows et podcasts","Tanggle","Team Fortress 2","Teamfight Manager 2","Teamfight Tactics","Teeth Cutter","Terraria","The Arrangement","The Backrooms Deluxe","The Bazaar","The Binding of Isaac: Repentance","The Crew: Motorfest","The Elder Scrolls IV: Oblivion","The Elder Scrolls Online","The Elder Scrolls V: Skyrim","The Elder Scrolls V: Skyrim - Special Edition","The First Berserker: Khazan","The First Descendant","The House Always Wins","The Inn-Sanity","The Isle","The Last Caretaker","The Last of Us Part I","The Last of Us Part II Remastered","The Legend of Zelda: A Link Between Worlds","The Legend of Zelda: A Link to the Past","The Legend of Zelda: Breath of the Wild","The Legend of Zelda: Majora's Mask","The Legend of Zelda: Ocarina of Time","The Legend of Zelda: Tears of the Kingdom","The Legend of Zelda: The Minish Cap","The Legend of Zelda: Twilight Princess","The Longest Journey","The Mortuary Assistant","The Operative: No One Lives Forever","The Other Side","The Outer Worlds 2","The Outlast Trials","The Quinfall","The Rake Sees You","The Seven Deadly Sins: Origin","The Sims 4","The Texas Chain Saw Massacre","The Witcher 3: Wild Hunt","They Are Billions","Throne and Liberty","Tibia","Tom Clancy's The Division 2","Tom Clancy's The Division: Resurgence","Tomodachi Life: Living the Dream","Total War: WARHAMMER III","Touhou Project","Tournament Poker","Town to City","Trackmania","Trails in the Sky 1st Chapter","Twitch Plays","UFL","Ultima Online","Ultimate Marvel vs. Capcom 3","Umamusume: Pretty Derby","Undisputed","Utawarerumono: Past and Present Rediscovered","V Rising","VALORANT","VRChat","Valheim","Vintage Story","Visage","Voices of the Void","WUCHANG: Fallen Feathers","WWE 2K26","War Thunder","Warcraft III","Warframe","Warhammer","Warhammer 40,000: Chaos Gate - Daemonhunters","Warhammer 40,000: Darktide","Warhammer 40,000: Mechanicus II","Warhammer 40,000: Space Marine II","Warhammer Online: Age of Reckoning","Warhammer: Vermintide 2","Wartales","What's the Password?","Where Winds Meet","White Knuckle","Windrose","Wizard101","Words On Stream","Workers & Resources: Soviet Republic","World of Tanks","World of Tanks Console","World of Tanks: Heat","World of Warcraft","World of Warships","Wuthering Waves","XCOM 2","Xenoblade Chronicles 3","Yakuza 0: Director's Cut","Yakuza Kiwami","Yoshi and the Mysterious Book","Yu-Gi-Oh! Master Duel","Zelda II: The Adventure of Link","Zenless Zone Zero","co-working et etudes","eFootball","iRacing","inZOI","osu!","theHunter: Call of the Wild","Ecriture et lecture","Evenements speciaux"]; const getCategories = () => TWITCH_CATEGORIES; const getChannelFromHref = href => (href || '').split('?')[0].replace(/^\//, '').split('/')[0].toLowerCase(); const getCategoryFromCard = card => card.querySelector('[data-a-target="preview-card-game-link"]')?.textContent?.trim() ?? ''; const getSidebarCatEl = link => link.querySelector('.side-nav-card__metadata p') ?? link.querySelector('[data-a-target="side-nav-card-metadata"] p:last-of-type') ?? [...link.querySelectorAll('p[title]')].find((p, i) => i > 0) ?? null; const getCategoryFromSidebar = link => getSidebarCatEl(link)?.textContent?.trim() ?? ''; const findChannelLinkInCard = card => card.querySelector('a[data-a-target="preview-card-channel-link"]') ?? card.querySelector('a[data-a-target="preview-card-image-link"]') ?? [...card.querySelectorAll('a[href]')].find(a => { const h = (a.getAttribute('href') || '').split('?')[0]; return /^\/[^\/]+$/.test(h) && !h.includes('.'); }); const saveTitle = (el, blurred) => { if (!el) return; if (blurred) { el.dataset.tsbTitle = el.getAttribute('title') || ''; el.removeAttribute('title'); } else if (el.dataset.tsbTitle !== undefined) { if (el.dataset.tsbTitle) el.setAttribute('title', el.dataset.tsbTitle); delete el.dataset.tsbTitle; } }; (() => { const s = document.createElement('style'); s.id = 'tsb-styles'; s.textContent = ` .tsb-reveal-controls { display: inline-flex; align-items: center; gap: 0; margin-left: 6px; position: relative; z-index: 20; vertical-align: middle; flex-shrink: 0; height: 22px; box-sizing: border-box; overflow: hidden; border: 1px solid rgba(173,173,184,.35); border-radius: 5px; background: rgba(24,24,27,.96); box-shadow: 0 1px 4px rgba(0,0,0,.35); } .tsb-reveal-option { display: inline-flex !important; align-items: center; justify-content: center; flex: 0 0 22px; width: 22px; min-width: 0 !important; min-height: 0 !important; height: 20px; padding: 0 !important; line-height: 1 !important; border: 0 !important; border-radius: 0; background: transparent !important; color: #adadb8 !important; cursor: pointer; opacity: .78; transition: color .12s, background-color .12s, opacity .12s; } .tsb-reveal-option + .tsb-reveal-option { border-left: 1px solid rgba(173,173,184,.25) !important; } .tsb-reveal-option:hover { opacity: 1; background: rgba(145,70,255,.18) !important; color: #e0c5ff !important; } .tsb-reveal-option.tsb-reveal-active { opacity: 1; background: rgba(145,70,255,.3) !important; color: #d7b8ff !important; } .tsb-reveal-option svg { display: block; width: 14px; height: 14px; } .tsb-blur-preview :is(img:not(.tw-image-avatar), video) { filter: blur(24px) brightness(0.35) !important; transition: none !important; } .tsb-reveal-option:focus-visible { outline: 2px solid #bf94ff; outline-offset: -2px; } .tsb-blur-title { filter: blur(5px) !important; user-select: none; } body[data-tsb-hover="blurred"] .tw-dialog-layer .tw-balloon, body[data-tsb-hover="blurred"] .online-side-nav-channel-tooltip, body[data-tsb-hover="blurred"] .online-side-nav-channel-tooltip__body { display: none !important; } .tw-dialog-layer > .tsb-sidebar-tooltip-hidden { display: none !important; } .tsb-shield-btn { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-left: 7px; background: none; border: none; cursor: pointer; color: #adadb8; border-radius: 50%; padding: 0; transition: color .15s, background .15s; vertical-align: middle; flex-shrink: 0; position: relative; top: -1px; } .tsb-shield-btn:hover { color: #bf94ff; background: rgba(191,148,255,.15); } .tsb-pinned-reveal-btn:hover, .tsb-pinned-reveal-btn[aria-pressed="true"] { color: #bf94ff !important; } .tsb-shield-count { position: absolute; top: -5px; right: -6px; background: #bf94ff; color: #0e0e10; font-size: 0.85rem; font-weight: 700; line-height: 1; padding: 1px 4px; border-radius: 8px; min-width: 14px; text-align: center; pointer-events: none; } #tsb-panel { position: fixed; top: 60px; right: 16px; z-index: 99999; width: 280px; max-height: 90vh; background: #303036; border: 1px solid #18181b; border-radius: 7px; box-shadow: 0 8px 32px rgba(0,0,0,.6); font-family: Inter, Roobert, sans-serif; font-size: 1.3rem; color: #efeff1; display: none; flex-direction: column; overflow: hidden; } #tsb-panel.tsb-open { display: flex; } .tsb-menu-header { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 10px; border-bottom: 1px solid #46464d; font-weight: 600; font-size: 1.25rem; color: #efeff1; } .tsb-menu-header > span { flex: 1; } .tsb-menu-page-body { padding: 6px 5px 9px; overflow-y: auto; } .tsb-menu-list { display: flex; flex-direction: column; gap: 0; } .tsb-menu-row { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 36px; padding: 0 9px; border: 0; border-radius: 0; background: transparent; color: #efeff1; text-align: left; font: 500 1.25rem Inter, Roobert, sans-serif; cursor: pointer; box-sizing: border-box; } .tsb-menu-row:hover { background: #3e3e43; } .tsb-menu-icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 18px; width: 18px; height: 18px; color: #efeff1; } .tsb-menu-icon svg { display: block; width: 17px; height: 17px; } .tsb-anti-spoil-icon { position: relative; } .tsb-menu-label { flex: 1; min-width: 0; } .tsb-menu-chevron { margin-left: auto; color: #adadb8; font-size: 1.8rem; line-height: 1; } .tsb-menu-divider { height: 1px; margin: 6px 7px; background: #46464d; } .tsb-menu-section-title { padding: 9px 9px 4px; color: #adadb8; font-size: 1.05rem; font-weight: 600; } .tsb-menu-toggle-row { position: relative; } .tsb-menu-toggle-row input { position: absolute; right: 10px; width: 1px; height: 1px; opacity: 0; } .tsb-menu-switch { position: relative; flex: 0 0 30px; width: 30px; height: 17px; margin-left: auto; border: 1px solid #6b6b73; border-radius: 999px; background: #45454b; transition: background .14s, border-color .14s; } .tsb-menu-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 11px; height: 11px; border-radius: 50%; background: #efeff1; transition: transform .14s; } .tsb-menu-toggle-row input:checked + .tsb-menu-switch { background: #9147ff; border-color: #9147ff; } .tsb-menu-toggle-row input:checked + .tsb-menu-switch::after { transform: translateX(13px); } .tsb-menu-toggle-row input:focus-visible + .tsb-menu-switch { outline: 2px solid #bf94ff; outline-offset: 2px; } .tsb-panel-back { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 28px; padding: 0; border: 0; background: none; color: #efeff1; font: 500 1.8rem Inter, Roobert, sans-serif; cursor: pointer; } #tsb-panel-close { background: none; border: none; cursor: pointer; color: #adadb8; padding: 2px; border-radius: 4px; display: flex; align-items: center; transition: color .15s; } #tsb-panel-close:hover { color: #efeff1; } #tsb-panel-list { list-style: none; margin: 0; padding: 6px 0; max-height: 320px; overflow-y: auto; flex-shrink: 0; } #tsb-panel-list:empty::after { content: "Aucune chaîne masquée"; display: block; padding: 14px 16px; color: #adadb8; font-style: italic; } .tsb-panel-row { border-bottom: 1px solid rgba(255,255,255,.05); } .tsb-panel-row:last-child { border-bottom: none; } .tsb-panel-row-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 14px 4px; gap: 8px; } .tsb-panel-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .tsb-panel-name a { color: #efeff1; text-decoration: none; transition: color .15s; } .tsb-panel-name a:hover { color: #bf94ff; text-decoration: underline; } .tsb-panel-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: #3a3a3d; } .tsb-panel-avatar-placeholder { width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; background: #3a3a3d; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #adadb8; font-weight: 700; text-transform: uppercase; } .tsb-panel-del { background: none; border: none; cursor: pointer; color: #adadb8; padding: 2px; border-radius: 4px; display: flex; align-items: center; flex-shrink: 0; transition: color .15s, background .15s; } .tsb-panel-del:hover { color: #f04747; background: rgba(240,71,71,.12); } .tsb-enable-btn:hover { color: #bf94ff; background: rgba(191,148,255,.15); } .tsb-panel-row.tsb-disabled .tsb-panel-name a { opacity: .55; } .tsb-undo-btn { color: #bf94ff !important; } .tsb-undo-btn:hover { color: #efeff1 !important; background: rgba(191,148,255,.15) !important; } .tsb-panel-row.tsb-pending .tsb-panel-name a { color: #f04747; text-decoration: line-through; } .tsb-panel-row.tsb-pending .tsb-mode-toggle { opacity: 0.3; pointer-events: none; } .tsb-panel-row.tsb-pending .tsb-cond-area { opacity: 0.3; pointer-events: none; } .tsb-mode-toggle { display: flex; background: #0e0e10; border-radius: 6px; padding: 2px; gap: 2px; margin: 2px 14px 6px; } .tsb-mode-btn { flex: 1; background: none; border: none; border-radius: 4px; color: #adadb8; cursor: pointer; font-size: 1.05rem; font-family: inherit; padding: 5px 2px; transition: background .15s, color .15s; white-space: nowrap; line-height: 1.2; } .tsb-mode-btn:hover:not(.tsb-mode-active) { color: #efeff1; background: rgba(255,255,255,.07); } .tsb-mode-btn.tsb-mode-active { background: #bf94ff; color: #0e0e10; font-weight: 700; } .tsb-cond-area { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 2px 14px 8px; } .tsb-cond-tag { display: inline-flex; align-items: center; gap: 3px; background: rgba(191,148,255,.15); color: #bf94ff; border: 1px solid rgba(191,148,255,.25); border-radius: 10px; padding: 2px 6px 2px 8px; font-size: 1.1rem; } .tsb-cond-tag-del { background: none; border: none; cursor: pointer; color: #bf94ff; padding: 0; display: flex; align-items: center; opacity: 0.5; transition: opacity .15s; } .tsb-cond-tag-del:hover { opacity: 1; } .tsb-add-cond-btn { background: none; border: 1px dashed #3a3a3d; border-radius: 10px; color: #adadb8; cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 2px 8px; transition: border-color .15s, color .15s; font-family: inherit; } .tsb-add-cond-btn:hover { border-color: #bf94ff; color: #bf94ff; } #tsb-panel-add { display: flex; gap: 6px; padding: 10px 14px; border-top: 1px solid #3a3a3d; } #tsb-panel-input { flex: 1; background: #0e0e10; border: 1px solid #3a3a3d; border-radius: 4px; color: #efeff1; padding: 5px 8px; font-size: 1.2rem; outline: none; font-family: inherit; } #tsb-panel-input:focus { border-color: #bf94ff; } #tsb-panel-input::placeholder { color: #adadb8; } #tsb-panel-addBtn { background: #bf94ff; color: #0e0e10; border: none; border-radius: 4px; padding: 5px 10px; font-size: 1.2rem; font-weight: 700; cursor: pointer; transition: background .15s; } #tsb-panel-addBtn:hover { background: #a970ff; } .tsb-cat-picker { padding: 0 14px 10px; box-sizing: border-box; } .tsb-cat-search { background: #0e0e10; border: 1px solid #bf94ff; border-radius: 6px; color: #efeff1; padding: 5px 9px; font-size: 1.1rem; outline: none; font-family: inherit; width: 100%; box-sizing: border-box; display: block; margin-bottom: 4px; } .tsb-cat-search::placeholder { color: #5a5a6a; } .tsb-cat-list { max-height: 140px; overflow-y: auto; background: #0e0e10; border: 1px solid #3a3a3d; border-radius: 6px; } .tsb-cat-item { padding: 5px 10px; cursor: pointer; font-size: 1.1rem; color: #efeff1; transition: background .1s; } .tsb-cat-item:hover { background: rgba(191,148,255,.18); } .tsb-cat-item-custom { color: #adadb8; border-top: 1px solid #2a2a2d; font-style: italic; } .tsb-cat-empty { color: #5a5a6a; font-style: italic; padding: 7px 10px; font-size: 1.1rem; } .tsb-whitelist-row { display: flex; align-items: center; gap: 8px; padding: 2px 14px 8px; font-size: 1.1rem; color: #adadb8; } #tsb-keywords { padding: 8px 14px 10px; border-top: 1px solid #3a3a3d; } #tsb-keyword-label { display: block; margin-bottom: 6px; color: #adadb8; font-size: 1.1rem; } #tsb-keyword-list { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; max-height: 72px; overflow-y: auto; } .tsb-keyword-tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border: 1px solid rgba(191,148,255,.25); border-radius: 10px; background: rgba(191,148,255,.12); color: #bf94ff; font-size: 1.05rem; } .tsb-keyword-delete { padding: 0; border: 0; background: none; color: inherit; cursor: pointer; opacity: .65; font: inherit; line-height: 1; } .tsb-keyword-delete:hover { opacity: 1; } #tsb-keyword-form { display: flex; gap: 6px; } #tsb-keyword-input { min-width: 0; flex: 1; padding: 5px 8px; border: 1px solid #3a3a3d; border-radius: 4px; outline: none; background: #0e0e10; color: #efeff1; font-family: inherit; font-size: 1.1rem; } #tsb-keyword-input:focus { border-color: #bf94ff; } #tsb-keyword-addBtn { padding: 3px 9px; border: 0; border-radius: 4px; background: #bf94ff; color: #0e0e10; font-weight: 700; cursor: pointer; } .tsb-whitelist-row.tsb-pending { opacity: 0.3; pointer-events: none; } .tsb-panel-row.tsb-pending .tsb-enable-btn { opacity: .3; pointer-events: none; } .tsb-wl-toggle { position: relative; width: 32px; height: 18px; flex-shrink: 0; cursor: pointer; } .tsb-wl-toggle input { opacity: 0; width: 0; height: 0; position: absolute; } .tsb-wl-slider { position: absolute; inset: 0; background: #3a3a3d; border-radius: 18px; transition: background .2s; } .tsb-wl-slider::before { content: ''; position: absolute; width: 12px; height: 12px; border-radius: 50%; background: #fff; left: 3px; top: 3px; transition: transform .2s; } .tsb-wl-toggle input:checked + .tsb-wl-slider { background: #bf94ff; } .tsb-wl-toggle input:checked + .tsb-wl-slider::before { transform: translateX(14px); } #tsb-warning-overlay { position: fixed; inset: 0; z-index: 1000000; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.72); backdrop-filter: blur(4px); } #tsb-warning-dialog { box-sizing: border-box; width: min(420px, 100%); padding: 22px; color: #efeff1; background: #18181b; border: 1px solid #3a3a3d; border-radius: 12px; box-shadow: 0 16px 56px rgba(0,0,0,.65); font: 14px/1.5 Inter, Roobert, sans-serif; } #tsb-warning-dialog h2 { margin: 0 0 8px; font-size: 18px; line-height: 1.3; color: #f0e6ff; } #tsb-warning-dialog p { margin: 0; color: #c5c5cb; } #tsb-warning-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; } #tsb-warning-actions button { min-height: 36px; padding: 0 14px; border-radius: 6px; cursor: pointer; font: 600 13px Inter, Roobert, sans-serif; } #tsb-warning-stay { color: #efeff1; background: #303036; border: 1px solid #46464d; } #tsb-warning-open { color: #fff; background: #9147ff; border: 1px solid #9147ff; } #tsb-warning-actions button:hover { filter: brightness(1.12); } `; (document.head || document.documentElement).appendChild(s); })(); function injectDynamicCSS() { document.getElementById('tsb-dynamic')?.remove(); if (!isSettingEnabled(SETTING_KEYS.antiSpoil)) return; const db = getDB(); const channels = Object.keys(db).filter(ch => /^[a-z0-9_]+$/i.test(ch) && db[ch].enabled !== false && !pendingDelete.has(ch) ); if (!channels.length) return; const rules = []; const s = document.createElement('style'); s.id = 'tsb-dynamic'; channels.forEach(ch => { const reveal = getRevealMode(ch); const article = `article:has(a[href="/${ch}"])`; const searchA = `[data-a-target="search-result-live-channel"]:has(a[href="/${ch}"])`; const searchDiv = `div.search-result-card:has(a[href="/${ch}"])`; const preview = [ `${article} img:not(.tw-image-avatar)`, `${article} video`, `${searchDiv} img.search-result-card__img`, `${searchDiv} video`, ]; const titles = [ `${article} a[data-a-target="preview-card-channel-link"] :is(h3, h4)`, `${article} [data-a-target="preview-card-title-link"] :is(h3, h4)`, `${article} [data-a-target="preview-card-title-link"]`, `${searchA} [data-test-selector="search-result-live-channel__title"]`, `${searchDiv} [data-test-selector="search-result-live-channel__title"]`, ]; // L'attribut protège les cartes recyclées pendant l'identification de la catégorie. if (reveal !== 'full') { const waitingArticle = `:not([data-tsb-ready="${ch}"])`; const waitingSearchA = `${searchA}:not([data-tsb-ready="${ch}"])`; const waitingSearchDiv = `${searchDiv}:not([data-tsb-ready="${ch}"])`; if (reveal !== 'title') { const pendingPreview = [ `${article}${waitingArticle} img:not(.tw-image-avatar)`, `${article}${waitingArticle} video`, `${waitingSearchDiv} img.search-result-card__img`, `${waitingSearchDiv} video`, `${waitingSearchA} img:not(.tw-image-avatar)`, `${waitingSearchA} video`, ]; rules.push(`${pendingPreview.join(',\n')} { filter: blur(24px) brightness(.35) !important; transition: none !important; }`); } if (!reveal) { const pendingTitles = [ `${article}${waitingArticle} a[data-a-target="preview-card-channel-link"] :is(h3, h4)`, `${article}${waitingArticle} [data-a-target="preview-card-title-link"] :is(h3, h4)`, `${article}${waitingArticle} [data-a-target="preview-card-title-link"]`, `${waitingSearchA} [data-test-selector="search-result-live-channel__title"]`, `${waitingSearchDiv} [data-test-selector="search-result-live-channel__title"]`, ]; rules.push(`${pendingTitles.join(',\n')} { filter: blur(5px) !important; user-select: none !important; }`); } } if (db[ch].mode === 'always' && reveal !== 'full') { rules.push(`${preview.slice(0, 2).join(',\n')} { filter: blur(24px) brightness(.35) !important; transition: none !important; }`); if (!db[ch].whitelist && !reveal) { rules.push(`${titles.slice(0, 3).join(',\n')} { filter: blur(5px) !important; user-select: none; }`); } } }); if (!rules.length) return; s.textContent = rules.join('\n'); (document.head || document.documentElement).appendChild(s); } injectDynamicCSS(); const mkX = n => ``; const iconEye = ``; const iconEyeOff = ``; const iconShield = ``; const iconSettings = ``; const iconClose = mkX(15); const iconUndo = ``; function toggleTemporaryReveal(ch, mode) { const key = ch.toLowerCase(); if (getRevealMode(ch) === mode) temporaryReveal.delete(key); else temporaryReveal.set(key, mode); refreshAll(); } function getCardBlurState(ch, cat, title) { const masked = isBlurred(ch, cat); return [ masked && getRevealMode(ch) !== 'full', isTitleBlurred(ch, title, cat), ]; } function syncRevealControls(controls, ch, cat, title) { const visible = isSettingEnabled(SETTING_KEYS.revealButtons) && isSettingEnabled(SETTING_KEYS.antiSpoil) && ((isInList(ch) && isChannelEnabled(ch) && isBlurred(ch, cat)) || titleMatchesKeyword(title)); controls.style.display = visible ? 'inline-flex' : 'none'; const current = getRevealMode(ch); controls.querySelectorAll('.tsb-reveal-option').forEach(button => { const active = button.dataset.revealMode === current; button.classList.toggle('tsb-reveal-active', active); button.setAttribute('aria-pressed', String(active)); }); } function makeRevealControls(ch) { const controls = document.createElement('span'); controls.className = 'tsb-reveal-controls'; controls.style.display = 'none'; controls.setAttribute('aria-label', 'Révélation temporaire'); [ { mode: 'title', icon: '', title: 'Afficher le titre seulement; recliquer pour tout remasquer', }, { mode: 'full', icon: '', title: 'Afficher le titre et l’aperçu; recliquer pour tout remasquer', }, ].forEach(option => { const button = document.createElement('button'); button.type = 'button'; button.className = 'tsb-reveal-option'; button.dataset.tsbControl = '1'; button.dataset.revealMode = option.mode; button.innerHTML = option.icon; button.title = option.title; button.setAttribute('aria-label', option.title); button.addEventListener('click', event => { event.preventDefault(); event.stopPropagation(); toggleTemporaryReveal(ch, option.mode); }); controls.appendChild(button); }); return controls; } function attachCardControls(host, ch) { const reveal = makeRevealControls(ch); host.append(reveal); } function applyCardBlur(card, blurPreview, blurTitle) { card.classList.toggle('tsb-blur-preview', blurPreview); const previewLink = card.querySelector('[data-a-target="preview-card-image-link"]') ?? card.querySelector('a[href] img:not(.tw-image-avatar)')?.closest('a'); if (previewLink) { previewLink.classList.toggle('tsb-blur-preview', blurPreview); } card.querySelectorAll('.tsb-hover-block').forEach(overlay => overlay.remove()); const titleEl = card.querySelector('a[data-a-target="preview-card-channel-link"] :is(h3, h4)') ?? card.querySelector('[data-a-target="preview-card-title-link"] :is(h3, h4)') ?? card.querySelector('[data-a-target="preview-card-title-link"]'); if (titleEl) { titleEl.classList.toggle('tsb-blur-title', blurTitle); saveTitle(titleEl, blurTitle); saveTitle(titleEl.closest('a'), blurTitle); } } function applySearchCardBlur(card, blurPreview, blurTitle) { card.querySelectorAll('img.search-result-card__img').forEach(img => { img.style.filter = blurPreview ? 'blur(24px) brightness(0.35)' : ''; img.style.transition = 'none'; }); const titleEl = card.querySelector('[data-test-selector="search-result-live-channel__title"]'); if (titleEl) { titleEl.style.filter = blurTitle ? 'blur(5px)' : ''; titleEl.style.userSelect = blurTitle ? 'none' : ''; saveTitle(titleEl, blurTitle); } } function updateSidebarBlur(link) { const ch = link.dataset.tsbSideChannel; if (!ch) return; const catEl = getSidebarCatEl(link); if (catEl) { catEl.classList.remove('tsb-blur-title'); saveTitle(catEl, false); } } function refreshAll() { document.querySelectorAll('article[data-tsb-done]').forEach(card => { const ch = card.dataset.tsbChannel; if (!ch) return; const cat = getCategoryFromCard(card); const title = card.querySelector(':is(h3,h4)')?.textContent ?? ''; applyCardBlur(card, ...getCardBlurState(ch, cat, title)); card.dataset.tsbReady = ch; const reveal = card.querySelector('.tsb-reveal-controls'); if (reveal) syncRevealControls(reveal, ch, cat, title); }); document.querySelectorAll('[data-a-target="search-result-live-channel"][data-tsb-search-done], div.search-result-card[data-tsb-search-done]').forEach(card => { const ch = card.dataset.tsbChannel; if (!ch) return; const catEl = card.querySelector('p[data-test-selector="search-result-live-channel__category"]') ?? card.querySelector('[data-a-target="preview-card-game-link"]') ?? card.querySelector('a[href*="/directory/category"]'); const cat = catEl?.textContent?.trim() ?? ''; const title = card.querySelector('[data-test-selector="search-result-live-channel__title"]')?.textContent ?? ''; applySearchCardBlur(card, ...getCardBlurState(ch, cat, title)); card.dataset.tsbReady = ch; card.closest('[data-a-target="search-result-live-channel"]')?.setAttribute('data-tsb-ready', ch); card.querySelectorAll('div.search-result-card').forEach(result => result.setAttribute('data-tsb-ready', ch)); const reveal = card.querySelector('.tsb-reveal-controls'); if (reveal) syncRevealControls(reveal, ch, cat, title); }); document.querySelectorAll('a[data-test-selector="followed-channel"][data-tsb-side-done]') .forEach(updateSidebarBlur); injectDynamicCSS(); } function buildCatPicker(ch, li, addBtn) { addBtn.style.display = 'none'; const picker = document.createElement('div'); picker.className = 'tsb-cat-picker'; const input = document.createElement('input'); input.className = 'tsb-cat-search'; input.type = 'text'; input.placeholder = 'Rechercher une categorie...'; input.setAttribute('autocomplete', 'off'); const listEl = document.createElement('div'); listEl.className = 'tsb-cat-list'; const render = q => { listEl.innerHTML = ''; const query = (q || '').toLowerCase().trim(); const existing = new Set(getEntry(ch)?.cats ?? []); const filtered = TWITCH_CATEGORIES.filter(c => !existing.has(c.toLowerCase()) && (!query || c.toLowerCase().includes(query)) ).slice(0, 60); if (!filtered.length && !query) { const empty = document.createElement('div'); empty.className = 'tsb-cat-empty'; empty.textContent = 'Toutes les categories sont deja ajoutees'; listEl.appendChild(empty); return; } filtered.forEach(cat => { const item = document.createElement('div'); item.className = 'tsb-cat-item'; item.textContent = cat; item.addEventListener('mousedown', e => { e.preventDefault(); if (addCat(ch, cat.toLowerCase())) { buildCondArea(ch, li); refreshAll(); } }); listEl.appendChild(item); }); if (query && !TWITCH_CATEGORIES.some(c => c.toLowerCase() === query)) { const custom = document.createElement('div'); custom.className = 'tsb-cat-item tsb-cat-item-custom'; custom.textContent = '+ Ajouter "' + q.trim() + '"'; custom.addEventListener('mousedown', e => { e.preventDefault(); if (addCat(ch, q.trim())) { buildCondArea(ch, li); refreshAll(); } }); listEl.appendChild(custom); } }; input.addEventListener('input', () => render(input.value)); input.addEventListener('keydown', e => { if (e.key === 'Escape') { buildCondArea(ch, li); return; } if (e.key === 'Enter') { const first = listEl.querySelector('.tsb-cat-item'); if (first) first.dispatchEvent(new MouseEvent('mousedown', { bubbles: true })); } }); input.addEventListener('blur', () => setTimeout(() => { if (!picker.contains(document.activeElement)) buildCondArea(ch, li); }, 200) ); render(''); picker.append(input, listEl); li.appendChild(picker); setTimeout(() => input.focus(), 0); } function buildCondArea(ch, li) { li.querySelector('.tsb-cond-area')?.remove(); li.querySelector('.tsb-cat-picker')?.remove(); const entry = getEntry(ch); if (!entry || entry.mode === 'always') return; const area = document.createElement('div'); area.className = 'tsb-cond-area'; entry.cats.forEach(cat => { const tag = document.createElement('span'); tag.className = 'tsb-cond-tag'; const text = document.createElement('span'); text.textContent = cat; const del = document.createElement('button'); del.className = 'tsb-cond-tag-del'; del.title = `Retirer "${cat}"`; del.innerHTML = mkX(9); del.addEventListener('click', e => { e.stopPropagation(); removeCat(ch, cat); buildCondArea(ch, li); refreshAll(); }); tag.append(text, del); area.appendChild(tag); }); const addBtn = document.createElement('button'); addBtn.className = 'tsb-add-cond-btn'; addBtn.textContent = '+ catégorie'; addBtn.addEventListener('click', e => { e.stopPropagation(); buildCatPicker(ch, li, addBtn); }); area.appendChild(addBtn); li.appendChild(area); } const AVATAR_KEY = 'tsb_avatars'; let _avatarCache = null; const getAvatarCache = () => { if (_avatarCache) return _avatarCache; try { _avatarCache = JSON.parse(GM_getValue(AVATAR_KEY, '{}')); } catch { _avatarCache = {}; } return _avatarCache; }; const saveAvatarCache = cache => { _avatarCache = cache; GM_setValue(AVATAR_KEY, JSON.stringify(cache)); }; function cacheAvatar(ch, url) { if (!ch || !url || url.includes('default')) return; const cache = getAvatarCache(), k = ch.toLowerCase(); if (cache[k] === url) return; cache[k] = url; saveAvatarCache(cache); } function getAvatarUrl(ch) { const k = ch.toLowerCase(); const selectors = [ `a[data-test-selector="followed-channel"][href="/${k}"] img.tw-image-avatar`, `article:has(a[href="/${k}"]) img.tw-image-avatar`, `[data-a-target="search-result-live-channel"]:has(a[href="/${k}"]) img.tw-image-avatar`, ]; for (const sel of selectors) { const img = document.querySelector(sel); if (img?.src) { cacheAvatar(k, img.src); return img.src; } } return getAvatarCache()[k] ?? null; } const makePlaceholder = ch => { const div = document.createElement('div'); div.className = 'tsb-panel-avatar-placeholder'; div.textContent = ch[0].toUpperCase(); return div; }; function makeAvatarEl(ch) { const url = getAvatarUrl(ch); if (!url) return makePlaceholder(ch); const img = document.createElement('img'); img.className = 'tsb-panel-avatar'; img.src = url; img.alt = ch; img.onerror = () => { const cache = getAvatarCache(); delete cache[ch.toLowerCase()]; saveAvatarCache(cache); img.replaceWith(makePlaceholder(ch)); }; return img; } function scanAllAvatarsOnPage() { const allAvatars = [...document.querySelectorAll('img.tw-image-avatar')].filter(img => !img.closest('nav') && !img.closest('[data-a-target="user-menu"]') && !img.closest('[data-a-target="top-nav-avatar"]') ); for (const img of allAvatars) { if (!img.src) continue; let ch = null; const altKey = img.alt?.toLowerCase().trim(); if (altKey && isInList(altKey)) { ch = altKey; } if (!ch) { const anchor = img.closest('a[href]') ?? img.parentElement?.closest('a[href]'); if (anchor) { const candidate = (anchor.getAttribute('href') || '').replace(/\?.*/, '').split('/').filter(Boolean)[0]?.toLowerCase(); if (candidate && isInList(candidate)) ch = candidate; } } if (!ch) { const parts = location.pathname.replace(/\/+$/, '').split('/').filter(Boolean); if (parts.length === 1) { const pageChannel = parts[0].toLowerCase(); if (isInList(pageChannel) && altKey === pageChannel) ch = pageChannel; } } if (ch) cacheAvatar(ch, img.src); } } function buildChannelRow(ch) { const k = ch.toLowerCase(); const isPending = pendingDelete.has(k); const li = document.createElement('li'); li.className = 'tsb-panel-row' + (isPending ? ' tsb-pending' : '') + (!isChannelEnabled(ch) ? ' tsb-disabled' : ''); const header = document.createElement('div'); header.className = 'tsb-panel-row-header'; const nameSpan = document.createElement('span'); nameSpan.className = 'tsb-panel-name'; nameSpan.innerHTML = `/${ch}`; const enableBtn = document.createElement('button'); enableBtn.className = 'tsb-panel-del tsb-enable-btn'; const syncEnableBtn = () => { const enabled = isChannelEnabled(ch); enableBtn.innerHTML = enabled ? iconEyeOff : iconEye; enableBtn.title = enabled ? 'Désactiver le masquage (réglages conservés)' : 'Réactiver le masquage'; enableBtn.setAttribute('aria-label', enableBtn.title); li.classList.toggle('tsb-disabled', !enabled); }; syncEnableBtn(); enableBtn.addEventListener('click', () => { if (pendingDelete.has(k)) return; setChannelEnabled(ch, !isChannelEnabled(ch)); syncEnableBtn(); refreshAll(); updateShieldCount(); }); const delBtn = document.createElement('button'); delBtn.className = 'tsb-panel-del'; delBtn.title = `Supprimer ${ch}`; delBtn.innerHTML = mkX(13); if (isPending) delBtn.style.display = 'none'; const undoBtn = document.createElement('button'); undoBtn.className = 'tsb-panel-del tsb-undo-btn'; undoBtn.title = 'Annuler la suppression'; undoBtn.innerHTML = iconUndo; undoBtn.style.display = isPending ? '' : 'none'; delBtn.addEventListener('click', () => { pendingDelete.set(k, JSON.parse(JSON.stringify(getEntry(ch)))); li.classList.add('tsb-pending'); delBtn.style.display = 'none'; undoBtn.style.display = ''; refreshAll(); updateShieldCount(); }); undoBtn.addEventListener('click', () => { pendingDelete.delete(k); li.classList.remove('tsb-pending'); undoBtn.style.display = 'none'; delBtn.style.display = ''; refreshAll(); updateShieldCount(); }); header.append(makeAvatarEl(ch), nameSpan, enableBtn, delBtn, undoBtn); li.appendChild(header); const entry = getEntry(ch); const toggle = document.createElement('div'); toggle.className = 'tsb-mode-toggle'; [ { id: 'always', label: 'Toujours' }, { id: 'only', label: 'Uniquement pour' }, { id: 'except', label: 'Sauf pour' }, ].forEach(({ id, label }) => { const btn = document.createElement('button'); btn.className = 'tsb-mode-btn' + (entry.mode === id ? ' tsb-mode-active' : ''); btn.textContent = label; btn.dataset.mode = id; btn.addEventListener('click', () => { if (pendingDelete.has(k)) return; setMode(ch, id); toggle.querySelectorAll('.tsb-mode-btn').forEach(b => b.classList.toggle('tsb-mode-active', b.dataset.mode === id)); buildCondArea(ch, li); refreshAll(); }); toggle.appendChild(btn); }); li.appendChild(toggle); buildCondArea(ch, li); const wlRow = document.createElement('div'); wlRow.className = 'tsb-whitelist-row' + (isPending ? ' tsb-pending' : ''); const wlLabel = document.createElement('label'); wlLabel.className = 'tsb-wl-toggle'; const wlInput = document.createElement('input'); wlInput.type = 'checkbox'; wlInput.checked = !!getEntry(ch)?.whitelist; const wlSlider = document.createElement('span'); wlSlider.className = 'tsb-wl-slider'; wlLabel.append(wlInput, wlSlider); const wlText = document.createElement('span'); wlText.textContent = 'Whitelist titres (bonjour, discussion…)'; wlInput.addEventListener('change', () => { if (pendingDelete.has(k)) return; setWhitelist(ch, wlInput.checked); refreshAll(); injectDynamicCSS(); }); wlRow.append(wlLabel, wlText); li.appendChild(wlRow); return li; } let panel = null; let panelPage = 'home'; function buildPanel() { if (panel) return panel; panel = document.createElement('div'); panel.id = 'tsb-panel'; document.body.appendChild(panel); panel.addEventListener('click', event => { const target = event.target instanceof Element ? event.target : event.target?.parentElement; const pageButton = target?.closest('[data-tsb-page]'); if (pageButton) { renderPanelPage(pageButton.dataset.tsbPage); return; } if (target?.closest('[data-tsb-back]')) { renderPanelHome(); return; } if (target?.closest('[data-tsb-close]')) closePanel(); }); document.addEventListener('mousedown', event => { if (panel?.classList.contains('tsb-open') && !panel.contains(event.target)) closePanel(); }, true); return panel; } function renderPanelHome() { if (!panel) return; if (panelPage === 'anti-spoil') { commitPendingDeletes(); refreshAll(); updateShieldCount(); } panelPage = 'home'; const iconTheater = ''; const iconHome = ''; panel.innerHTML = `
Paramètres
`; updateShieldCount(); } function appendSettingToggle(host, key, title, description, onChange) { const row = document.createElement('label'); row.className = 'tsb-menu-row tsb-menu-toggle-row'; row.title = description || title; const icon = document.createElement('span'); icon.className = 'tsb-menu-icon'; const iconMarkup = { [SETTING_KEYS.antiSpoil]: iconShield, [SETTING_KEYS.titleKeywords]: '', [SETTING_KEYS.openWarning]: '', [SETTING_KEYS.revealButtons]: '', [SETTING_KEYS.theater]: '', [SETTING_KEYS.extensions]: '', [SETTING_KEYS.volumeWheel]: '', [SETTING_KEYS.continueWatching]: '', [SETTING_KEYS.featuredCarousel]: '', [SETTING_KEYS.hidePinnedChat]: '', [SETTING_KEYS.hideDropHighlights]: '', [SETTING_KEYS.hideHypeTrain]: '', [SETTING_KEYS.hideChatLeaderboard]: '', [SETTING_KEYS.hideSharedChat]: '', }; icon.innerHTML = iconMarkup[key] || ''; const titleEl = document.createElement('span'); titleEl.className = 'tsb-menu-label'; titleEl.textContent = title; const input = document.createElement('input'); input.type = 'checkbox'; input.checked = isSettingEnabled(key); input.setAttribute('aria-label', title); input.addEventListener('change', () => { saveSetting(key, input.checked); onChange?.(input.checked); }); const toggle = document.createElement('span'); toggle.className = 'tsb-menu-switch'; row.append(icon, titleEl, input, toggle); host.appendChild(row); } function renderPanelPage(page) { if (!panel) return; if (panelPage === 'anti-spoil' && page !== 'anti-spoil') { commitPendingDeletes(); refreshAll(); updateShieldCount(); } panelPage = page; const titles = { 'anti-spoil': 'Chaînes anti-spoil', 'home-content': 'Accueil', player: 'Stream', }; const view = document.createElement('div'); view.className = 'tsb-panel-view'; view.innerHTML = `
${titles[page]}
`; panel.replaceChildren(view); const body = view.querySelector('#tsb-app-page-body'); if (page === 'anti-spoil') { body.innerHTML = `
Chaînes protégées
    `; const options = body.querySelector('#tsb-anti-spoil-settings'); appendSettingToggle(options, SETTING_KEYS.antiSpoil, 'Protection anti-spoil', 'Applique tes règles de masquage aux cartes Twitch.', enabled => { if (!enabled) temporaryReveal.clear(); refreshAll(); updateShieldCount(); }); appendSettingToggle(options, SETTING_KEYS.titleKeywords, 'Filtrer par mots-clés', 'Masque les titres qui contiennent les mots de ta liste.', () => refreshAll()); appendSettingToggle(options, SETTING_KEYS.openWarning, 'Confirmer avant ouverture', 'Demande confirmation avant d’ouvrir une chaîne masquée.'); appendSettingToggle(options, SETTING_KEYS.revealButtons, 'Révéler le titre ou l’aperçu', 'Affiche temporairement les informations masquées.', enabled => { if (!enabled) temporaryReveal.clear(); refreshAll(); }); const input = body.querySelector('#tsb-panel-input'); const doAdd = () => { const val = input.value.trim() .replace(/^https?:\/\/(www\.)?twitch\.tv\//i, '').replace(/\//g, ''); if (!val) return; if (addChannel(val)) { input.value = ''; body.querySelector('#tsb-panel-list').appendChild(buildChannelRow(val.toLowerCase())); refreshAll(); updateShieldCount(); } else { input.style.borderColor = '#f04747'; setTimeout(() => { input.style.borderColor = ''; }, 800); } }; body.querySelector('#tsb-panel-addBtn').addEventListener('click', doAdd); input.addEventListener('keydown', e => { if (e.key === 'Enter') doAdd(); }); const keywordInput = body.querySelector('#tsb-keyword-input'); const doAddKeyword = () => { const word = keywordInput.value.trim().replace(/\s+/g, ' '); if (!normalizeText(word)) return; const words = getTitleKeywords(); if (words.some(saved => normalizeText(saved) === normalizeText(word))) { keywordInput.style.borderColor = '#f04747'; setTimeout(() => { keywordInput.style.borderColor = ''; }, 800); return; } saveTitleKeywords([...words, word]); keywordInput.value = ''; refreshKeywordList(); refreshAll(); keywordInput.focus(); }; body.querySelector('#tsb-keyword-addBtn').addEventListener('click', doAddKeyword); keywordInput.addEventListener('keydown', event => { if (event.key === 'Enter') doAddKeyword(); }); refreshPanelList(); return; } const options = document.createElement('div'); options.className = 'tsb-menu-list'; body.appendChild(options); if (page === 'home-content') { appendSettingToggle(options, SETTING_KEYS.featuredCarousel, 'Masquer le carrousel à la une', 'Masque le grand aperçu des streams mis en avant sur l’accueil Twitch.'); appendSettingToggle(options, SETTING_KEYS.continueWatching, 'Masquer « Regarder la suite »', 'Masque cette rangée de vidéos sur la page d’accueil Twitch.'); } else if (page === 'player') { appendSettingToggle(options, SETTING_KEYS.theater, 'Mode théâtre automatique', 'Active le mode théâtre au démarrage d’un stream.'); appendSettingToggle(options, SETTING_KEYS.extensions, 'Masquer les extensions Twitch', 'Cache les overlays et panneaux d’extensions qui recouvrent le stream.'); appendSettingToggle(options, SETTING_KEYS.volumeWheel, 'Changer le volume à la molette', 'Chaque cran modifie le volume de 1 %.'); appendSettingToggle(options, SETTING_KEYS.hidePinnedChat, 'Masquer les messages épinglés', 'Masque les cartes de messages épinglés au-dessus du chat.'); appendSettingToggle(options, SETTING_KEYS.hideDropHighlights, 'Masquer les alertes de Drops', 'Masque les cartes Twitch qui annoncent les Drops dans le chat.'); appendSettingToggle(options, SETTING_KEYS.hideHypeTrain, 'Masquer le train de la hype', 'Masque les éléments Twitch identifiés comme liés au train de la hype.'); appendSettingToggle(options, SETTING_KEYS.hideChatLeaderboard, 'Masquer les leaderboards', 'Masque les classements de subs, Bits, clips et vues, ainsi que les objectifs d’abonnements au-dessus du chat.'); appendSettingToggle(options, SETTING_KEYS.hideSharedChat, 'Masquer le bandeau de chat partagé', 'Masque les annonces de démarrage du chat partagé au-dessus du chat.'); } } function refreshKeywordList() { if (!panel || panelPage !== 'anti-spoil') return; const list = panel.querySelector('#tsb-keyword-list'); if (!list) return; list.replaceChildren(); getTitleKeywords().forEach((word, index) => { const tag = document.createElement('span'); tag.className = 'tsb-keyword-tag'; const label = document.createElement('span'); label.textContent = word; const remove = document.createElement('button'); remove.type = 'button'; remove.className = 'tsb-keyword-delete'; remove.textContent = '×'; remove.title = 'Supprimer « ' + word + ' »'; remove.addEventListener('click', () => { saveTitleKeywords(getTitleKeywords().filter((_, i) => i !== index)); refreshKeywordList(); refreshAll(); }); tag.append(label, remove); list.appendChild(tag); }); } function refreshPanelList() { if (!panel || panelPage !== 'anti-spoil') return; const list = panel.querySelector('#tsb-panel-list'); if (!list) return; list.innerHTML = ''; Object.keys(getDB()).sort().forEach(ch => list.appendChild(buildChannelRow(ch))); refreshKeywordList(); updateShieldCount(); } function updateShieldCount() { document.querySelector('.tsb-shield-btn .tsb-shield-count')?.remove(); const icon = panel?.querySelector('.tsb-anti-spoil-icon'); if (!icon) return; const count = Object.keys(getDB()).filter(ch => getDB()[ch].enabled !== false && !pendingDelete.has(ch) ).length; let badge = icon.querySelector('.tsb-shield-count'); if (!count) { badge?.remove(); return; } if (!badge) { badge = document.createElement('span'); badge.className = 'tsb-shield-count'; icon.appendChild(badge); } badge.textContent = count; } const openPanel = menuRect => { buildPanel(); if (menuRect) { const left = Math.max(8, Math.min(menuRect.left, window.innerWidth - menuRect.width - 8)); const top = Math.max(8, Math.min(menuRect.top, window.innerHeight - 80)); panel.style.left = `${Math.round(left)}px`; panel.style.top = `${Math.round(top)}px`; panel.style.right = 'auto'; panel.style.width = `${Math.round(menuRect.width)}px`; panel.style.maxHeight = `${Math.max(200, window.innerHeight - top - 8)}px`; } else { panel.style.left = ''; panel.style.top = ''; panel.style.right = ''; panel.style.width = ''; panel.style.maxHeight = ''; } renderPanelHome(); panel.classList.add('tsb-open'); }; const closePanel = () => { if (!panel) return; commitPendingDeletes(); panel.classList.remove('tsb-open'); refreshAll(); updateShieldCount(); }; function getProfileMenuRect(profileNode, logoutBtn) { let node = profileNode; let fallback = null; while (node && node !== document.body) { if (node.contains(logoutBtn)) { fallback = node; const rect = node.getBoundingClientRect(); if (rect.width >= 180 && rect.height >= 100) { return { left: rect.left, top: rect.top, width: rect.width, height: rect.height }; } } node = node.parentElement; } const rect = fallback?.getBoundingClientRect(); return rect ? { left: rect.left, top: rect.top, width: rect.width, height: rect.height } : null; } function processUserMenu() { const logoutBtn = document.querySelector('[data-a-target="dropdown-logout"]'); if (!logoutBtn) return; const nameEl = document.querySelector('[data-a-target="user-display-name"]') ?? logoutBtn.closest('[class]')?.querySelector('p[title], h6, p'); if (!nameEl) return; const nameRow = nameEl.parentElement; if (!nameRow) return; Object.assign(nameRow.style, { display: 'flex', alignItems: 'center', width: '100%' }); let btn = nameRow.querySelector('.tsb-shield-btn'); if (!btn) { btn = document.createElement('button'); btn.className = 'tsb-shield-btn'; btn.title = 'Paramètres'; btn.setAttribute('aria-label', btn.title); btn.innerHTML = iconSettings; btn.style.marginLeft = 'auto'; nameRow.appendChild(btn); } if (!btn.dataset.tsbActionBound) { btn.dataset.tsbActionBound = '1'; btn.addEventListener('click', event => { event.stopPropagation(); event.preventDefault(); const menuRect = getProfileMenuRect(nameRow, logoutBtn); openPanel(menuRect); const toggle = document.querySelector('[data-a-target="header-account-menu-toggle"]') ?? document.querySelector('[data-a-target="user-menu-toggle"]'); toggle ? toggle.click() : document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, cancelable: true })); }); } updateShieldCount(); } function processPinnedRevealButton() { const selector = 'button[data-test-selector="chat-viewer-list"]'; const existing = document.querySelector('.tsb-pinned-reveal-btn'); const pinnedMessageExists = !!document.querySelector('.community-highlight-stack__card .pinned-chat__highlight-card'); if (!isSettingEnabled(SETTING_KEYS.hidePinnedChat) || !pinnedMessageExists) { existing?.remove(); if (pinnedChatTemporarilyRevealed) { pinnedChatTemporarilyRevealed = false; updateChatEventStyle(); } return; } const communityButton = document.querySelector(selector); if (!communityButton?.parentElement) { existing?.remove(); return; } if (existing?.parentElement === communityButton.parentElement) return; existing?.remove(); const button = communityButton.cloneNode(true); button.classList.add('tsb-pinned-reveal-btn'); button.removeAttribute('data-test-selector'); button.removeAttribute('data-a-target'); button.type = 'button'; const updateButton = () => { const label = pinnedChatTemporarilyRevealed ? 'Remasquer les messages épinglés' : 'Afficher temporairement les messages épinglés'; button.title = label; button.setAttribute('aria-label', label); button.setAttribute('aria-pressed', String(pinnedChatTemporarilyRevealed)); }; const svg = button.querySelector('svg'); if (svg) { svg.setAttribute('fill', 'none'); svg.setAttribute('stroke', 'currentColor'); svg.setAttribute('stroke-width', '1.8'); svg.setAttribute('stroke-linecap', 'round'); svg.setAttribute('stroke-linejoin', 'round'); svg.innerHTML = ''; } updateButton(); button.addEventListener('click', event => { event.preventDefault(); event.stopPropagation(); pinnedChatTemporarilyRevealed = !pinnedChatTemporarilyRevealed; updateButton(); updateChatEventStyle(); }); communityButton.parentElement.insertBefore(button, communityButton); } function processCard(card) { card.querySelectorAll('.tsb-btn').forEach(button => button.remove()); const channelLink = findChannelLinkInCard(card); const linkedChannel = getChannelFromHref(channelLink?.getAttribute('href')); const ch = linkedChannel || card.dataset.tsbChannel; if (!ch || ch.includes('.')) return; if (card.dataset.tsbChannel && card.dataset.tsbChannel !== ch) { card.querySelectorAll('.tsb-btn, .tsb-reveal-controls').forEach(control => control.remove()); card.dataset.tsbDone = ''; } card.dataset.tsbChannel = ch; if (!card.dataset.tsbDone) { card.dataset.tsbDone = '1'; const avatarImg = card.querySelector('img.tw-image-avatar'); if (avatarImg?.src && isInList(ch)) cacheAvatar(ch, avatarImg.src); } if (!card.querySelector('.tsb-reveal-controls') && channelLink) { const pseudoRow = channelLink.querySelector('p[title]')?.parentElement; const host = pseudoRow ?? channelLink; if (pseudoRow) Object.assign(pseudoRow.style, { display: 'flex', alignItems: 'center', gap: '4px' }); attachCardControls(host, ch); } const cat = getCategoryFromCard(card); const title = card.querySelector(':is(h3,h4)')?.textContent ?? ''; applyCardBlur(card, ...getCardBlurState(ch, cat, title)); card.dataset.tsbReady = ch; const reveal = card.querySelector('.tsb-reveal-controls'); if (reveal) syncRevealControls(reveal, ch, cat, title); } let leaveTimer = null, revealTimer = null, balloonObs = null, prevBlurred = false; const TOOLTIP_SELECTOR = '.tw-balloon, .online-side-nav-channel-tooltip, [role="tooltip"], ' + '[data-a-target*="tooltip" i], [data-test-selector*="tooltip" i], ' + '[class*="tooltip" i], [class*="balloon" i], [class*="popover" i], ' + '[data-a-target*="hover-card" i], [data-test-selector*="hover-card" i], [class*="hover-card" i]'; const SIDEBAR_TOOLTIP_TEXT_SELECTOR = '.online-side-nav-channel-tooltip__body p, .tw-dialog-layer [role="tooltip"], ' + '.tw-dialog-layer [data-a-target*="tooltip" i], .tw-dialog-layer [data-test-selector*="tooltip" i], ' + '.tw-dialog-layer [class*="tooltip" i], .tw-dialog-layer [class*="hover-card" i]'; const getSidebarTooltipTitle = (ch = '') => { const channelText = normalizeText(ch); if (!channelText) return null; const candidates = new Set([ ...document.querySelectorAll(TOOLTIP_SELECTOR), ...document.querySelectorAll(SIDEBAR_TOOLTIP_TEXT_SELECTOR), ]); for (const node of candidates) { const text = normalizeText(node.textContent); const nameMatches = text === channelText || (` ${text} `).includes(` ${channelText} `); const linkMatches = [...node.querySelectorAll('a[href]')].some(anchor => { try { const firstPath = new URL(anchor.href, location.href).pathname.split('/').filter(Boolean)[0]; return firstPath?.toLowerCase() === ch.toLowerCase(); } catch { return false; } }); if (nameMatches || linkMatches) { return node.querySelector('.online-side-nav-channel-tooltip__body p')?.textContent ?? node.textContent ?? ''; } } return null; }; const hiddenSidebarTooltipContainers = new Set(); const markSidebarTooltipContainers = (ch = '') => { const layer = document.querySelector('.tw-dialog-layer'); if (!layer) return; const channelText = normalizeText(ch); for (const container of layer.children) { const text = normalizeText(container.textContent); const nameMatches = !!channelText && (` ${text} `).includes(` ${channelText} `); const linkMatches = !!ch && [...container.querySelectorAll('a[href]')].some(anchor => { try { const firstPath = new URL(anchor.href, location.href).pathname.split('/').filter(Boolean)[0]; return firstPath?.toLowerCase() === ch.toLowerCase(); } catch { return false; } }); const hasSidebarTooltip = container.matches('.online-side-nav-channel-tooltip, .online-side-nav-channel-tooltip__body') || container.querySelector('.online-side-nav-channel-tooltip, .online-side-nav-channel-tooltip__body'); const identifiedTooltip = (container.matches(TOOLTIP_SELECTOR) || container.querySelector(TOOLTIP_SELECTOR)) && (nameMatches || linkMatches); if (hasSidebarTooltip || identifiedTooltip) { container.classList.add('tsb-sidebar-tooltip-hidden'); hiddenSidebarTooltipContainers.add(container); } } }; const clearSidebarTooltipContainers = () => { hiddenSidebarTooltipContainers.forEach(node => node.classList.remove('tsb-sidebar-tooltip-hidden')); hiddenSidebarTooltipContainers.clear(); }; const cancelReveal = () => { clearTimeout(revealTimer); balloonObs?.disconnect(); balloonObs = null; }; function processSidebarItem(link) { if (link.dataset.tsbSideDone) return; link.dataset.tsbSideDone = '1'; const ch = (link.getAttribute('href') || '').split('/').filter(Boolean).pop()?.toLowerCase(); if (!ch) return; link.dataset.tsbSideChannel = ch; const sideAvatarImg = link.querySelector('img.tw-image-avatar'); if (sideAvatarImg?.src && isInList(ch)) cacheAvatar(ch, sideAvatarImg.src); updateSidebarBlur(link); link.addEventListener('mouseenter', () => { clearTimeout(leaveTimer); cancelReveal(); const sideCat = getCategoryFromSidebar(link); const revealMode = getRevealMode(ch); const channelMasked = isBlurred(ch, sideCat) && revealMode !== 'full' && revealMode !== 'title'; const hasTitleRules = isSettingEnabled(SETTING_KEYS.titleKeywords) && getTitleKeywords().length > 0; const checkTitle = channelMasked || hasTitleRules || prevBlurred; const canRevealByTitle = hasTitleRules || !!getEntry(ch)?.whitelist || !channelMasked; const setTooltipHidden = hidden => { if (hidden) { document.body.dataset.tsbHover = 'blurred'; markSidebarTooltipContainers(ch); } else { delete document.body.dataset.tsbHover; clearSidebarTooltipContainers(); } }; const evaluateTooltip = () => { const title = getSidebarTooltipTitle(ch); // Twitch réutilise parfois cette bulle : attendre l'identification de son contenu. if (title === null) return false; const hidden = isTitleBlurred(ch, title, sideCat); setTooltipHidden(hidden); prevBlurred = hidden; return true; }; // Pré-masquer le contenu recyclé, puis révéler les bulles ordinaires après vérification. if (!checkTitle) { setTooltipHidden(false); prevBlurred = false; return; } if (channelMasked || prevBlurred) { setTooltipHidden(true); prevBlurred = true; } else { setTooltipHidden(false); prevBlurred = false; } const root = document.querySelector('.tw-dialog-layer') ?? document.body; balloonObs = new MutationObserver(() => { markSidebarTooltipContainers(ch); if (canRevealByTitle && evaluateTooltip() && !document.body.dataset.tsbHover) cancelReveal(); }); balloonObs.observe(root, { childList: true, subtree: true, characterData: true }); if (canRevealByTitle) { revealTimer = setTimeout(() => { if (evaluateTooltip()) { clearTimeout(revealTimer); revealTimer = null; if (!document.body.dataset.tsbHover) cancelReveal(); } else if (!channelMasked) { // Un titre inconnu ne doit pas masquer une bulle ordinaire. setTooltipHidden(false); prevBlurred = false; cancelReveal(); } }, channelMasked ? 400 : 0); } }); link.addEventListener('mouseleave', () => { cancelReveal(); leaveTimer = setTimeout(() => { delete document.body.dataset.tsbHover; clearSidebarTooltipContainers(); prevBlurred = false; }, 700); }); } function processSearchCard(card) { card.querySelectorAll('.tsb-btn').forEach(button => button.remove()); const nameLink = card.querySelector('[data-test-selector="search-result-live-channel__name"] a[href]'); const linkedChannel = getChannelFromHref(nameLink?.getAttribute('href')); const ch = linkedChannel || card.dataset.tsbChannel; if (!ch) return; if (card.dataset.tsbChannel && card.dataset.tsbChannel !== ch) { card.querySelectorAll('.tsb-btn, .tsb-reveal-controls').forEach(control => control.remove()); card.dataset.tsbSearchDone = ''; } card.dataset.tsbChannel = ch; if (!card.dataset.tsbSearchDone) { card.dataset.tsbSearchDone = '1'; const avatarImg = card.querySelector('img.tw-image-avatar'); if (avatarImg?.src && isInList(ch)) cacheAvatar(ch, avatarImg.src); } const getCatEl = () => card.querySelector('p[data-test-selector="search-result-live-channel__category"]') ?? card.querySelector('[data-a-target="preview-card-game-link"]') ?? card.querySelector('a[href*="/directory/category"]'); if (!card.querySelector('.tsb-reveal-controls')) { const nameRow = card.querySelector('[data-test-selector="search-result-live-channel__name"]')?.parentElement; if (nameRow) { Object.assign(nameRow.style, { display: 'flex', alignItems: 'center', gap: '4px' }); attachCardControls(nameRow, ch); } } const cat = getCatEl()?.textContent?.trim() ?? ''; const title = card.querySelector('[data-test-selector="search-result-live-channel__title"]')?.textContent ?? ''; applySearchCardBlur(card, ...getCardBlurState(ch, cat, title)); card.dataset.tsbReady = ch; card.closest('[data-a-target="search-result-live-channel"]')?.setAttribute('data-tsb-ready', ch); card.querySelectorAll('div.search-result-card').forEach(result => result.setAttribute('data-tsb-ready', ch)); const reveal = card.querySelector('.tsb-reveal-controls'); if (reveal) syncRevealControls(reveal, ch, cat, title); } const scan = () => { document.querySelectorAll('article').forEach(processCard); document.querySelectorAll('[data-a-target="search-result-live-channel"], div.search-result-card').forEach(processSearchCard); document.querySelectorAll('a[data-test-selector="followed-channel"]').forEach(processSidebarItem); processUserMenu(); scanAllAvatarsOnPage(); }; let allowProtectedNavigation = false; function showStreamWarning(link, href, openNewTab) { if (document.getElementById('tsb-warning-overlay')) return; const overlay = document.createElement('div'); overlay.id = 'tsb-warning-overlay'; overlay.setAttribute('role', 'presentation'); const dialog = document.createElement('section'); dialog.id = 'tsb-warning-dialog'; dialog.setAttribute('role', 'dialog'); dialog.setAttribute('aria-modal', 'true'); dialog.setAttribute('aria-labelledby', 'tsb-warning-title'); const heading = document.createElement('h2'); heading.id = 'tsb-warning-title'; heading.textContent = 'Chaîne protégée'; const message = document.createElement('p'); message.textContent = 'Cette chaîne est masquée par l’anti-spoil. Son stream peut révéler des éléments. Voulez-vous l’ouvrir quand même ?'; const actions = document.createElement('div'); actions.id = 'tsb-warning-actions'; const stay = document.createElement('button'); stay.id = 'tsb-warning-stay'; stay.type = 'button'; stay.textContent = 'Rester ici'; const open = document.createElement('button'); open.id = 'tsb-warning-open'; open.type = 'button'; open.textContent = 'Ouvrir le stream'; actions.append(stay, open); dialog.append(heading, message, actions); overlay.appendChild(dialog); const close = () => { overlay.remove(); document.removeEventListener('keydown', onKeyDown, true); }; const onKeyDown = event => { if (event.key === 'Escape') { event.preventDefault(); close(); } if (event.key === 'Tab') { event.preventDefault(); (document.activeElement === stay ? open : stay).focus(); } }; stay.addEventListener('click', close); overlay.addEventListener('click', event => { if (event.target === overlay) close(); }); open.addEventListener('click', () => { close(); if (openNewTab) { window.open(href, '_blank', 'noopener'); } else if (link.isConnected) { allowProtectedNavigation = true; try { link.click(); } finally { allowProtectedNavigation = false; } } else { window.location.assign(href); } }); document.addEventListener('keydown', onKeyDown, true); (document.body || document.documentElement).appendChild(overlay); stay.focus(); } function handleProtectedNavigation(event) { if (!isSettingEnabled(SETTING_KEYS.openWarning) || allowProtectedNavigation || event.defaultPrevented || event.button > 1) return; const target = event.target instanceof Element ? event.target : event.target?.parentElement; if (!target || target.closest('#tsb-panel, #tsb-warning-overlay, .tsb-reveal-controls, [data-tsb-control="1"]')) return; const link = target?.closest('a[href]'); if (!link) return; let url; try { url = new URL(link.href, location.href); } catch { return; } if (!['www.twitch.tv', 'twitch.tv'].includes(url.hostname.toLowerCase())) return; const parts = url.pathname.split('/').filter(Boolean); if (parts.length !== 1 || !/^[a-z0-9_]+$/i.test(parts[0])) return; const ch = parts[0].toLowerCase(); const card = link.closest('article, [data-a-target="search-result-live-channel"], div.search-result-card'); let category = ''; if (card?.matches('article')) category = getCategoryFromCard(card); else if (card) { const categoryEl = card.querySelector('p[data-test-selector="search-result-live-channel__category"]') ?? card.querySelector('[data-a-target="preview-card-game-link"]') ?? card.querySelector('a[href*="/directory/category"]'); category = categoryEl?.textContent?.trim() ?? ''; } else { const sidebar = link.closest('a[data-test-selector="followed-channel"]'); if (sidebar) category = getCategoryFromSidebar(sidebar); } const title = card?.querySelector('[data-test-selector="search-result-live-channel__title"], [data-a-target="preview-card-title-link"], h3, h4')?.textContent?.trim() ?? ''; const channelMasked = isInList(ch) && isChannelEnabled(ch) && isBlurred(ch, category) && getRevealMode(ch) !== 'full'; if (!channelMasked && !isTitleBlurred(ch, title, category)) return; event.preventDefault(); event.stopPropagation(); event.stopImmediatePropagation?.(); showStreamWarning(link, url.href, event.button === 1 || event.ctrlKey || event.metaKey || event.shiftKey || link.target === '_blank'); } const observe = () => { document.addEventListener('click', handleProtectedNavigation, true); document.addEventListener('auxclick', handleProtectedNavigation, true); let timer = null, pendingUserMenu = false, pendingPinnedRevealButton = false; const pendingCards = new Map(); const cardSelector = 'article, [data-a-target="search-result-live-channel"], div.search-result-card'; const spoilerContentSelector = 'h3, h4, [data-a-target="preview-card-title-link"], [data-a-target="preview-card-game-link"], ' + '[data-test-selector="search-result-live-channel__title"], [data-test-selector="search-result-live-channel__category"], ' + 'img.search-result-card__img, video'; const invalidateReady = card => { card.removeAttribute('data-tsb-ready'); card.closest('[data-a-target="search-result-live-channel"]')?.removeAttribute('data-tsb-ready'); card.closest('div.search-result-card')?.removeAttribute('data-tsb-ready'); card.querySelectorAll('[data-a-target="search-result-live-channel"], div.search-result-card') .forEach(result => result.removeAttribute('data-tsb-ready')); }; const queueCard = card => { if (card.matches('article')) pendingCards.set(card, processCard); else pendingCards.set(card, processSearchCard); }; const collectNode = node => { const element = node.nodeType === 1 ? node : node.parentElement; if (!element) return; const parentCard = element.closest?.(cardSelector); const changesSpoilerContent = element.matches?.(spoilerContentSelector) || !!element.closest?.(spoilerContentSelector) || !!element.querySelector?.(spoilerContentSelector); if (parentCard) { if (changesSpoilerContent) invalidateReady(parentCard); queueCard(parentCard); } if (node.nodeType !== 1) return; if (node.matches('.pinned-chat__highlight-card') || node.querySelector('.pinned-chat__highlight-card') || element.closest?.('.pinned-chat__highlight-card')) pendingPinnedRevealButton = true; if (node.matches('button[data-test-selector="chat-viewer-list"]') || node.querySelector('button[data-test-selector="chat-viewer-list"]')) pendingPinnedRevealButton = true; if (node.matches(cardSelector)) { if (changesSpoilerContent) invalidateReady(node); queueCard(node); } node.querySelectorAll(cardSelector).forEach(card => { if (changesSpoilerContent) invalidateReady(card); queueCard(card); }); if (node.matches('a[data-test-selector="followed-channel"]')) processSidebarItem(node); node.querySelectorAll('a[data-test-selector="followed-channel"]').forEach(processSidebarItem); if (node.matches('[data-a-target="dropdown-logout"]') || node.querySelector('[data-a-target="dropdown-logout"]')) pendingUserMenu = true; }; new MutationObserver(mutations => { for (const mutation of mutations) { if (mutation.type === 'characterData' || mutation.type === 'attributes') collectNode(mutation.target); mutation.addedNodes.forEach(collectNode); if (mutation.type === 'childList') { for (const removedNode of mutation.removedNodes) { if (removedNode.nodeType === 1 && (removedNode.matches('.pinned-chat__highlight-card') || removedNode.querySelector('.pinned-chat__highlight-card'))) { pendingPinnedRevealButton = true; break; } } } } if (!pendingCards.size && !pendingUserMenu && !pendingPinnedRevealButton) return; clearTimeout(timer); timer = setTimeout(() => { timer = null; pendingCards.forEach((process, card) => { if (card.isConnected) process(card); }); pendingCards.clear(); if (pendingUserMenu) processUserMenu(); pendingUserMenu = false; if (pendingPinnedRevealButton) processPinnedRevealButton(); pendingPinnedRevealButton = false; }, 60); }).observe(document.body, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ['href'], }); scan(); processPinnedRevealButton(); const origPush = history.pushState.bind(history); history.pushState = (...args) => { origPush(...args); setTimeout(scan, 100); }; window.addEventListener('popstate', () => setTimeout(scan, 100)); }; document.body ? observe() : document.addEventListener('DOMContentLoaded', observe); })();