ubershmekel / redditp

Convert any reddit page to a presentation or slide show

Home Page:https://redditp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not able to click the unmute button in redgif v3 in redditp

parthmahadik004 opened this issue · comments

I am not able to click the unmute button. Please look into the problem.

Previously I used a Tampermonkey script to click the unmute button but it doesn't work anymore after v3.

After a little research, this seems to work. Create a script and paste

// ==UserScript==
// @name         Auto unmute
// @description Auto unmute redgif in redditp
// @version      1.0.0
// @match        https://www.redgifs.com/ifr/*
// @match        https://www.redgifs.com/watch/*
// @match        https://redditp.com/*
// ==/UserScript==

const mouseClickEvents = ['mousedown', 'click', 'mouseup'];

// From https://stackoverflow.com/questions/40091000/simulate-click-event-on-react-element
function simulateMouseClick(element){
  mouseClickEvents.forEach(mouseEventType =>
    element.dispatchEvent(
      new MouseEvent(mouseEventType, {
          view: window,
          bubbles: true,
          cancelable: true,
          buttons: 1
      })
    )
  );
}

setTimeout(() => {

    let btn = document.querySelector('svg[class^="gear"]');    // Toggle HD
        if(btn) {
            simulateMouseClick(btn);
        }

    btn = document.querySelector('svg[class^="sound"]');    //Toggle Audio
        if(btn) {
            simulateMouseClick(btn);
        }
}, 500)    //adjust time

Please test now and let me know if it works.

I had the same issue except with the quality button and it works now. But the quality doesnt stay set as HD it always defaults to SD

Previously I used a Tampermonkey script to click the unmute button but it doesn't work anymore after v3.

After a little research, this seems to work. Create a script and paste

// ==UserScript==
// @name         Auto unmute
// @description Auto unmute redgif in redditp
// @version      1.0.0
// @match        https://www.redgifs.com/ifr/*
// @match        https://www.redgifs.com/watch/*
// @match        https://redditp.com/*
// ==/UserScript==

const mouseClickEvents = ['mousedown', 'click', 'mouseup'];

// From https://stackoverflow.com/questions/40091000/simulate-click-event-on-react-element
function simulateMouseClick(element){
  mouseClickEvents.forEach(mouseEventType =>
    element.dispatchEvent(
      new MouseEvent(mouseEventType, {
          view: window,
          bubbles: true,
          cancelable: true,
          buttons: 1
      })
    )
  );
}

setTimeout(() => {

    let btn = document.querySelector('svg[class^="gear"]');    // Toggle HD
        if(btn) {
            simulateMouseClick(btn);
        }

    btn = document.querySelector('svg[class^="sound"]');    //Toggle Audio
        if(btn) {
            simulateMouseClick(btn);
        }
}, 500)    //adjust time

Thank you for this.