S058: zap smoke green; plain hide spares players

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-14 07:37:48 -06:00
commit 4353f280f8

View file

@ -528,6 +528,7 @@ const COSMETIC_JS: &str = r#"(() => { if (!window.__nacre || window.__nacre.cosm
'40%{opacity:1;transform:scale(.97);clip-path:inset(0 round 28px)}70%{opacity:1;transform:scale(.72) rotate(-4deg);' +
'clip-path:inset(8% round 48%)}100%{opacity:0;transform:scale(0) rotate(-14deg);clip-path:inset(30% round 50%)}}\n';
const PLAYER = '.html5-video-player,.video-js,.jwplayer,.plyr,[data-vjs-player],.vjs-tech,.shaka-video-container,.dplayer';
const KEEP = 'video,audio,:has(video,audio)';
const gone = el => el.classList.add('__nz_gone');
// The slot closes up: only this last step animates size.
const collapse = el => { const st = el.style, set = (k, v) => st.setProperty(k, v, 'important');
@ -549,7 +550,7 @@ const COSMETIC_JS: &str = r#"(() => { if (!window.__nacre || window.__nacre.cosm
const handle = el => {
if (!(el instanceof Element) || el.__nz || !opts || !opts.animate) return;
el.__nz = 1;
if (el.matches('video,audio') || el.querySelector('video,audio')) return; // never kill a real player
if (el.matches(KEEP)) return; // never kill a real player
counted(1);
if (el.closest(PLAYER)) return gone(el); // ad UI inside a player: quietly
const r = el.getBoundingClientRect();
@ -564,12 +565,13 @@ const COSMETIC_JS: &str = r#"(() => { if (!window.__nacre || window.__nacre.cosm
opts = o || { animate: false };
let added = 0;
for (const sel of list) if (!selectors.has(sel)) { selectors.add(sel); added++;
if (!opts.animate) try { for (const el of document.querySelectorAll(sel)) if (!el.__nz) { el.__nz = 1; counted(1); } } catch (e) {} }
if (!opts.animate) try { for (const el of document.querySelectorAll(sel)) if (!el.__nz && !el.matches(KEEP)) { el.__nz = 1; counted(1); } } catch (e) {} }
if (!added) return 0;
if (!style) { style = document.createElement('style'); style.id = '__nacre_cosmetic'; }
// One rule per selector, so a bad selector only drops itself.
const rule = opts.animate ? '{animation:__nz_detect 1ms!important}' : '{display:none!important}';
style.textContent = BASE + [...selectors].map(s => s + rule).join('\n');
// Plain hiding leaves players alone too (`:is()` keeps a bad selector from breaking its rule's guard).
style.textContent = BASE + [...selectors].map(s => opts.animate ? s + '{animation:__nz_detect 1ms!important}'
: `:is(${s}):not(${KEEP}){display:none!important}`).join('\n');
if (!style.isConnected) (document.head || document.documentElement).appendChild(style);
return added;
}