Auto-Pause Redgifs

Auto-pauses videos from redgif on reddit

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        Auto-Pause Redgifs
// @description Auto-pauses videos from redgif on reddit
// @namespace   redgifs.com
// @match       *://*redgifs.com/*
// @match       *redgifs.com/*
// @include     *redgifs.com/*
// @match       https://www.redgifs.com/*
// @grant       none
// @license     GPLv2
// @author      laclcia
// @version     1.14
// ==/UserScript==

(function() {
  'use strict';

  console.log('Script loaded on Redgifs page'); // Debug message

  const waitTime = 1000; // Wait time between attempts in milliseconds (1 second)
  const maxAttempts = 6; // Maximum number of attempts to find the video

  let videoPaused = false; // Flag to track if video is paused

  function findAndPauseVideo() {
    const video = document.querySelector('a.videoLink video[src]'); // Use previous selector

    if (video && !videoPaused) { // Check video and paused flag
      console.log('Video element found'); // Debug message
      video.pause();
      console.log('Paused Redgif video');
      videoPaused = true; // Set flag to true after pausing
    }

    console.log('Video not found (attempt ', arguments[0], ')'); // Debug message with attempt count
  }

  for (let i = 0; i < maxAttempts && !videoPaused; i++) { // Check videoPaused in loop condition
    setTimeout(findAndPauseVideo.bind(null, i + 1), waitTime * i); // Call with attempt count
  }
})();