aboutsummaryrefslogtreecommitdiffstats
path: root/src/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/features')
-rw-r--r--src/features/messages.js39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/features/messages.js b/src/features/messages.js
index 158f0ee..797534e 100644
--- a/src/features/messages.js
+++ b/src/features/messages.js
@@ -9010,7 +9010,7 @@ export function messagesFeature(ctx) {
// c copy, t start) in its place ("What would it take … to have it play in
// line like other videos and YouTube videos do?", Adam, 2026-11-17).
// Only ever on a tap, never on scroll: a PAFF film starts a torrent swarm
- // in the viewer's browser.
+ // in the viewer's browser. Scrolled off, it pauses (paffWatch).
function paffEmbedUrl(url) {
let u;
try { u = new URL(url); } catch { return null; }
@@ -9018,6 +9018,42 @@ export function messagesFeature(ctx) {
const m = u.pathname.match(/^\/(movie\/[^/]+|show\/[^/]+\/s\d+e\d+)(?:\/play)?\/?$/i);
return m ? 'https://paff.club/embed/' + m[1] + u.search : null;
}
+ // A playing film pauses once its post is off the screen and carries on
+ // when it comes back, if it was us that paused it ("can you ask paff to
+ // do the pause command?", Adam, 2026-11-17). The embed takes
+ // {source:'paff', command} and tells us its state as {source:'paff', event}.
+ let paffObserver = null, paffHeard = false;
+ const paffSay = (box, command) => {
+ const f = box.querySelector('iframe');
+ try { f?.contentWindow?.postMessage({ source: 'paff', command }, 'https://paff.club'); } catch {}
+ };
+ function paffWatch(box) {
+ if (typeof window === 'undefined') return;
+ if (!paffHeard) {
+ paffHeard = true;
+ window.addEventListener('message', (e) => {
+ if (e.origin !== 'https://paff.club' || e.data?.source !== 'paff') return;
+ for (const b of document.querySelectorAll('.paff-embed[data-playing]')) {
+ if (b.querySelector('iframe')?.contentWindow !== e.source) continue;
+ if (e.data.event === 'playing') { b._paffPlaying = true; b._pausedByUs = false; }
+ else if (e.data.event === 'pause' || e.data.event === 'ended') b._paffPlaying = false;
+ }
+ });
+ }
+ if (typeof IntersectionObserver === 'undefined') return;
+ if (!paffObserver) paffObserver = new IntersectionObserver((entries) => {
+ for (const en of entries) {
+ const b = en.target;
+ if (!b.isConnected) { paffObserver.unobserve(b); continue; }
+ if (!en.isIntersecting) {
+ if (b._paffPlaying) { b._pausedByUs = true; paffSay(b, 'pause'); }
+ } else if (en.intersectionRatio >= 0.5 && b._pausedByUs) {
+ b._pausedByUs = false; paffSay(b, 'play');
+ }
+ }
+ }, { threshold: [0, 0.5] });
+ paffObserver.observe(box);
+ }
function paffEmbed(url, pv) {
const embed = paffEmbedUrl(url);
const load = (box) => {
@@ -9033,6 +9069,7 @@ export function messagesFeature(ctx) {
f.allowFullscreen = true;
f.referrerPolicy = 'strict-origin-when-cross-origin';
box.append(f);
+ paffWatch(box);
};
return h('div', {
class: 'yt-embed paff-embed',