// ==UserScript== // @name RedGifs Android AutoHD + Audio + UI (STABLE) // @namespace https://github.com/Invertex/RedGifs-AutoHD // @version 2.2.0 // @license AGPLv3 // @match https://www.redgifs.com/watch/* // @match https://www.redgifs.com/ifr/* // @grant none // ==/UserScript==
(() => { 'use strict';
const cfg = { autoHD: true, autoNext: true, autoUnmute: true, repeat: false, autoVolume: true, volume: 0.7, uiVisible: true };
let video; let panel; let toggleBtn; let audioUnlocked = false;
function getVideo() { return document.querySelector('video'); }
/* ===== UI ===== */ function createToggleButton() { if (toggleBtn) return; toggleBtn = document.createElement('div'); toggleBtn.textContent = 'RG'; toggleBtn.style.cssText = position: fixed; top: 10px; right: 10px; background: #000; color: #0f0; padding: 6px 8px; font: bold 12px monospace; border-radius: 6px; z-index: 2147483647;; toggleBtn.onclick = () => { cfg.uiVisible = !cfg.uiVisible; panel.style.display = cfg.uiVisible ? 'block' : 'none'; }; document.body.appendChild(toggleBtn); }
function createPanel() { if (panel) return;
panel = document.createElement('div');
panel.style.cssText = `
position: fixed;
top: 50px;
left: 10px;
background: rgba(0,0,0,0.85);
color: #0f0;
font: 12px monospace;
padding: 10px;
z-index: 2147483647;
border-radius: 8px;
width: 200px;
`;
panel.innerHTML = `
RedGifs Control
`;
document.body.appendChild(panel);
createToggleButton();
panel.querySelector('#hd').checked = cfg.autoHD;
panel.querySelector('#next').checked = cfg.autoNext;
panel.querySelector('#rep').checked = cfg.repeat;
panel.querySelector('#mute').checked = cfg.autoUnmute;
panel.querySelector('#vol').checked = cfg.autoVolume;
panel.querySelector('#unlock').onclick = () => {
audioUnlocked = true;
if (video) {
video.muted = false;
video.volume = cfg.volume;
video.play().catch(()=>{});
}
};
panel.onchange = () => {
cfg.autoHD = panel.querySelector('#hd').checked;
cfg.autoNext = panel.querySelector('#next').checked;
cfg.repeat = panel.querySelector('#rep').checked;
cfg.autoUnmute = panel.querySelector('#mute').checked;
cfg.autoVolume = panel.querySelector('#vol').checked;
};
}
/* ===== FEATURES ===== */ function applyAudio() { if (!video || !audioUnlocked) return; if (cfg.autoUnmute) video.muted = false; if (cfg.autoVolume) video.volume = cfg.volume; }
function applyHD() { if (!cfg.autoHD) return; const btn = [...document.querySelectorAll('button')].find(b => /hd/i.test(b.textContent)); if (btn) btn.click(); }
function handleEnd() { if (cfg.repeat) return; video.loop = false; if (!cfg.autoNext) return;
const next = document.querySelector('a[rel="next"]') ||
[...document.querySelectorAll('a[href*="/watch/"]')].pop();
if (next) next.click();
}
/* ===== LOOP ===== */ function loop() { if (!video) { video = getVideo(); if (video) { video.loop = false; // kill RedGifs repeat createPanel(); applyHD(); video.addEventListener('ended', handleEnd); } }
if (video && panel) {
applyAudio();
panel.querySelector('#info').innerHTML =
`HD: ${video.videoHeight >= 720}
` +
`Muted: ${video.muted}
` +
`Loop: ${video.loop}`;
}
setTimeout(loop, 300);
}
loop(); })();