Feature Pack with bug fixes for V2

This commit is contained in:
Ujwal223
2026-06-09 23:39:43 +05:45
parent f1bd12f0bd
commit 39b6545e4a
53 changed files with 7314 additions and 328 deletions
+33
View File
@@ -223,3 +223,36 @@ const String kAutoplayBlockerJS = r'''
}, true);
})();
''';
// Reinforcement observer — catches videos that Instagram creates after the
// prototype override (e.g. React re-renders). Runs a MutationObserver that
// pauses any <video> that tries to autoplay.
const String kAutoplayObserverJS = r'''
(function fgAutoplayObserver() {
if (window.__fgAutoplayObserverRunning) return;
window.__fgAutoplayObserverRunning = true;
function pauseIfBlocked(v) {
try {
if (window.__fgBlockAutoplay === false) return;
if (window.__focusgramSessionActive) return;
const url = window.location.href || '';
if (url.includes('/reels/') || url.includes('/reel/')) return;
if (v.paused) return;
if (v.getAttribute('data-fg-user-played') === '1') return;
v.pause();
} catch (_) {}
}
// Check all existing videos periodically
setInterval(function() {
document.querySelectorAll('video').forEach(pauseIfBlocked);
}, 500);
// Mark video as user-played on click
document.addEventListener('click', function(e) {
var v = e.target && e.target.closest ? e.target.closest('video') : null;
if (v) v.setAttribute('data-fg-user-played', '1');
}, true);
})();
''';