← back to kai-rin__netflix-autoplay-off

Function bodies 7 total

All specs Real LLM only Function bodies
updateBadge function · javascript · L7-L12 (6 LOC)
background.js
function updateBadge(enabled) {
  chrome.action.setBadgeText({ text: enabled ? 'ON' : 'OFF' });
  chrome.action.setBadgeBackgroundColor({
    color: enabled ? '#4CAF50' : '#9E9E9E'
  });
}
applyState function · javascript · L10-L15 (6 LOC)
content.js
  function applyState(enabled) {
    ROOT.dataset.nao = enabled ? 'on' : 'off';
    if (enabled) {
      pauseAllVideos();
    }
  }
isWatchPage function · javascript · L18-L20 (3 LOC)
content.js
  function isWatchPage() {
    return /^\/watch\//.test(window.location.pathname);
  }
pauseAllVideos function · javascript · L23-L29 (7 LOC)
content.js
  function pauseAllVideos() {
    if (isWatchPage()) return;
    document.querySelectorAll('video').forEach(function (video) {
      video.pause();
      video.autoplay = false;
    });
  }
startObserver function · javascript · L45-L72 (28 LOC)
content.js
  function startObserver() {
    var observer = new MutationObserver(function (mutations) {
      if (ROOT.dataset.nao !== 'on' || isWatchPage()) return;

      for (var i = 0; i < mutations.length; i++) {
        var addedNodes = mutations[i].addedNodes;
        for (var j = 0; j < addedNodes.length; j++) {
          var node = addedNodes[j];
          if (node.nodeType !== Node.ELEMENT_NODE) continue;

          if (node.tagName === 'VIDEO') {
            node.pause();
            node.autoplay = false;
          }

          if (node.querySelectorAll) {
            var videos = node.querySelectorAll('video');
            for (var k = 0; k < videos.length; k++) {
              videos[k].pause();
              videos[k].autoplay = false;
            }
          }
        }
      }
    });

    observer.observe(ROOT, { childList: true, subtree: true });
  }
isWatchPage function · javascript · L16-L18 (3 LOC)
inject.js
  function isWatchPage() {
    return /^\/watch\//.test(window.location.pathname);
  }
shouldBlock function · javascript · L21-L23 (3 LOC)
inject.js
  function shouldBlock() {
    return document.documentElement.dataset.nao !== 'off' && !isWatchPage();
  }