const checkAndStopVideo = setInterval(() => {
  const video = document.querySelector('video');

  if (video) {
    video.pause();
    video.currentTime = 0;
    clearInterval(checkAndStopVideo);

   






    const style = document.createElement('style');
    style.textContent = `
    @keyframes scroll-text {
      0% { transform: translateX(100%); }
      100% { transform: translateX(-100%); }
    }
    
    .scroll-container {
      position: fixed;
      bottom: 20px;
      left: 0;
      width: 100%;
      overflow: hidden;
      z-index: 9999;
      background-color: rgba(0, 0, 0, 0.7);
      padding: 10px;
      box-sizing: border-box;
    }
    
    .scroll-text {
      display: inline-block;
      white-space: nowrap;
      color: white;
      font-size: 16px;
      font-family: Arial, sans-serif;
      animation: scroll-text 30s linear infinite;
    }
    `;
    document.head.appendChild(style);







    

    const glitchStyle = document.createElement('style');
    glitchStyle.textContent = `
    @keyframes glitch-transition {
      0% { transform: none; }
      15% { transform: translate(2px, -2px) skew(1deg, 1deg); filter: contrast(150%) saturate(150%); }
      30% { transform: translate(-2px, 2px) skew(-1deg, -1deg); filter: hue-rotate(20deg); }
      45% { transform: translate(3px, 1px) skew(2deg, -2deg); filter: brightness(1.5); }
      60% { transform: none; }
      75% { transform: translate(-1px, -1px) skew(1deg, 0.5deg); }
      90% { transform: translate(1px, 1px) skew(-1deg, -1deg); }
      100% { transform: none; }
    }
    
    .glitch-transition {
      animation: glitch-transition 1.2s ease;
    }
    `;
    document.head.appendChild(glitchStyle);




    

 






const scrollContainer = document.createElement('div');
scrollContainer.classList.add('scroll-container');


const scrollText = document.createElement('div');
scrollText.classList.add('scroll-text');
scrollText.innerText = 
  "The Colectiv fire on October 30, 2015, killed 65 people due to corruption and negligence. " +
  "Cristian Piedone, then mayor of Sector 4, was convicted for abuse of power. " +
  "He issued permits for the nightclub despite its lack of fire safety measures."+
  "CORRUPTION INHERENTLY KILLS. JUSTICE FOR THE VICTIMS OF COLECTIV.";

scrollContainer.appendChild(scrollText);
document.body.appendChild(scrollContainer);













    const overlay1 = document.createElement('div');
    overlay1.style.position = 'fixed';
    overlay1.style.top = '200px';
    overlay1.style.left = '50px';
    overlay1.style.zIndex = '9999';
    overlay1.style.padding = '15px';
    overlay1.style.background = 'rgba(0, 0, 0, 0.85)';
    overlay1.style.color = 'white';
    overlay1.style.borderRadius = '10px';
    overlay1.style.fontFamily = 'Arial, sans-serif';
    overlay1.style.maxWidth = '300px';


    

    const protestText = document.createElement('div');
    protestText.innerText = 'Remember Piedone s part in Colectiv before you laugh at his carefully curated videos';
    protestText.style.fontSize = '16px';
    protestText.style.marginBottom = '10px';

    const protestImage1 = document.createElement('img');
    protestImage1.src = chrome.runtime.getURL('colectiv1.jpg');
    protestImage1.style.width = '100%';
    protestImage1.style.borderRadius = '8px';

    overlay1.appendChild(protestText);
    overlay1.appendChild(protestImage1);
    overlay1.style.opacity = '0';
    overlay1.style.transition = 'opacity 1s ease';
    document.body.appendChild(overlay1);
    overlay1.classList.add('flicker-animation');

    setTimeout(() => {
      overlay1.style.opacity = '1';
    }, 5000);

   







    const overlay2 = document.createElement('div');
    overlay2.style.position = 'fixed';
    overlay2.style.top = '260px';
    overlay2.style.right = '80px';
    overlay2.style.Index = '9999';
    overlay2.style.padding = '10px';
    overlay2.style.background = 'rgba(255, 255, 255, 0.1)';
    overlay2.style.borderRadius = '8px';
    overlay2.style.opacity = '0';
    overlay2.style.transition = 'opacity 1s ease';
    overlay2.classList.add('flicker-animation');
  


    setTimeout(() => {
      overlay2.style.opacity = '1';
    }, 6000);


    const protestImage2 = document.createElement('img');
    protestImage2.src = chrome.runtime.getURL('colectiv2.jpg');
    protestImage2.style.width = '200px';
    protestImage2.style.borderRadius = '8px';

    overlay2.appendChild(protestImage2);
    document.body.appendChild(overlay2);















    const videoOverlay = document.createElement('div');
 
setTimeout(() => {
  videoOverlay.style.opacity = '1';
  protestVideo.classList.add('glitch-transition');

  setTimeout(() => {
    protestVideo.classList.remove('glitch-transition');
  }, 1200);
}, 7000);

videoOverlay.style.position = 'fixed';
videoOverlay.style.top = '50%';
videoOverlay.style.left = '50%';
videoOverlay.style.transform = 'translate(-50%, -50%)';
videoOverlay.style.zIndex = '9999';
videoOverlay.style.border = '4px solid white';
videoOverlay.style.borderRadius = '12px';
videoOverlay.style.overflow = 'hidden';
videoOverlay.style.boxShadow = '0 0 20px black';
videoOverlay.style.maxWidth = '80vw';
videoOverlay.style.maxHeight = '60vh';
videoOverlay.style.opacity = '0';
videoOverlay.style.transition = 'opacity 1s ease';
videoOverlay.classList.add('fade-animation');




setTimeout(() => {
  videoOverlay.style.opacity = '1';
}, 7000);

const protestVideo = document.createElement('video');
protestVideo.src = chrome.runtime.getURL('colectivvideo.mp4');
protestVideo.autoplay = true;
protestVideo.muted = true;
protestVideo.loop = true;
protestVideo.style.width = '100%';
protestVideo.style.height = '100%';
protestVideo.style.objectFit = 'cover';

videoOverlay.appendChild(protestVideo);
document.body.appendChild(videoOverlay);
  }
}, 500);



function makeDraggable(element) {
  let isDragging = false;
  let offsetX, offsetY;

  element.addEventListener('mousedown', (e) => {
    isDragging = true;
    offsetX = e.clientX - element.getBoundingClientRect().left;
    offsetY = e.clientY - element.getBoundingClientRect().top;
    element.style.cursor = 'grabbing';
  });

  document.addEventListener('mousemove', (e) => {
    if (isDragging) {
      element.style.left = `${e.clientX - offsetX}px`;
      element.style.top = `${e.clientY - offsetY}px`;
    }
  });

  document.addEventListener('mouseup', () => {
    isDragging = false;
    element.style.cursor = 'grab';
  });
}


const fadeStyle = document.createElement('style');
fadeStyle.textContent = `
  @keyframes fadeInOut {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
  }

  .fade-animation {
    animation: fadeInOut 4s infinite;
  }
`;

document.head.appendChild(fadeStyle);





const flickerStyle = document.createElement('style');
flickerStyle.textContent = `
  @keyframes flicker {
    0%, 100% { opacity: 1; }
    25% { opacity: 0.9; }
    50% { opacity: 0.7; }
    75% { opacity: 0.85; }
  
  }

  .flicker-animation {
    animation: flicker 0.5s infinite;
  }
`;

document.head.appendChild(flickerStyle);

