r/userscripts • • Jan 16 '26

100% AI-generated Tampermonkey userscript — TikTok-style “Shorts Mode” overlay for fyptt.to (NSFW) v6.2.0 NSFW

0 Upvotes

I wanted a TikTok-style way to browse videos on fyptt.to (NSFW/adult site), so I had an AI generate a Tampermonkey userscript that adds a “Shorts Mode” overlay: click a video, then use keyboard/scroll to move through the feed.

Important disclaimer: this script is entirely AI-written (fully generated by AI). I did not manually write or tweak the core code myself. I’m sharing it as an AI-generated experiment, not claiming it as hand-made work.

What it does

  • Adds a toggleable Shorts Mode overlay (TikTok-like consumption)

  • One video at a time navigation

  • Keyboard + mouse wheel controls

  • Status indicator bottom-right (enabled/disabled)

Install / Setup (Tampermonkey)

  1. Install the Tampermonkey browser extension.

  2. Go to fyptt.to once (just to ensure it loads normally).

  3. Click the Tampermonkey icon in your browser toolbar.

  4. Choose Create a new script.

  5. Press Ctrl + A and delete everything.

  6. Paste the script code.

  7. Save (Ctrl + S).

  8. Go back to fyptt.to and reload the page.

  9. Press S to toggle Shorts Mode (check bottom-right for ON/OFF).

  10. Click a video to start.

Controls

  • Arrow Up: previous video

  • Arrow Down: next video

  • Mouse wheel up/down: same as Up/Down

  • Arrow Right: fast-forward

  • Arrow Left: rewind

  • Spacebar: pause / resume

  • M: mute / unmute

  • S: toggle Shorts Mode ON/OFF

Current limitation (pagination / preloaded videos)

Right now, you can only scroll through the videos that the site has already preloaded on the current page.

Since fyptt.to uses pagination at the bottom (Page 1 / 2 / 3 … and/or Next), the script currently works like this:

  • You can keep going down until you hit the end of the preloaded list (end of the page).

  • To continue, you need to:

    1. Exit the overlay,

    2. Click Next / Page 2,

    3. Enter the overlay again and continue scrolling.

Have fun gooning.
If you run into bugs or have feature wishes, let me know in the comments and I’ll collect them.

CODE:

// ==UserScript==

// u/nameFYPTT SHORTS v6.2.0

// u/namespacelocal.fyptt.shorts.dualplayer

// u/version6.2.0

// u/authorArvagnar

// u/description FYPTT Shorts Overlay (dual player). Pre-resolve player iframe to avoid interim page, Space=Pause/Play.

// u/matchhttps://fyptt.to/*

// u/run-atdocument-idle

// u/noframes

// u/grantnone

// ==/UserScript==

(() => {

'use strict';

window.__FYPTT_SHORTS_AUTHOR = 'Arvagnar';

const SEEK_SECONDS = 3;

const PHONE_MAX_H = 0.995;

const FRAME_MARGIN = 0.92;

const COOLDOWN_MS = 1200;

const END_EPSILON_SEC = 0.25;

const END_POLL_MS = 400;

const STORAGE_KEY = 'fyptt_shorts_enabled';

const ORIGIN = location.origin;

const DEFAULT_AUDIO_ON = true;

let userMuted = false;

const PLAYER_IFRAME_RE = /\/fyptt(st|str)\.php|\/fypttjwstr/i;

const PHONE_ASPECT = 9 / 16;

const WIDE_ENOUGH = PHONE_ASPECT + 0.06;

const FRAME_ASPECT_CAP = 1.25;

let frameAspect = PHONE_ASPECT;

let fitMode = 'cover';

let activeControlFrame = null;

let overlay, overlayFrame, overlayCover, badge;

let urls = [], index = -1;

let shortsEnabled = getShortsEnabled();

let wheelCooldownUntil = 0;

let cleanupFns = [];

let loadSeq = 0;

let coverSizerTimer = null;

function isTypingContext(el) {

if (!el) return false;

const tag = el.tagName?.toLowerCase();

return tag === 'input' || tag === 'textarea' || el.isContentEditable;

}

function isSpaceKey(e) {

return e.code === 'Space' || e.key === ' ' || e.key === 'Spacebar';

}

function getShortsEnabled() {

try {

const v = JSON.parse(localStorage.getItem(STORAGE_KEY));

return typeof v === 'boolean' ? v : false;

} catch { return false; }

}

function setShortsEnabled(v) {

localStorage.setItem(STORAGE_KEY, JSON.stringify(!!v));

}

function pickLargest(elements) {

let best = null;

let bestArea = 0;

for (const el of elements) {

if (!el || !el.getBoundingClientRect) continue;

const r = el.getBoundingClientRect();

const area = Math.max(0, r.width) * Math.max(0, r.height);

if (area > bestArea) { bestArea = area; best = el; }

}

return best;

}

function clamp(n, min, max) {

return Math.max(min, Math.min(max, n));

}

function cleanupAllBindings() {

for (const fn of cleanupFns) { try { fn(); } catch {} }

cleanupFns = [];

}

function showCover(txt = 'Loading…') {

if (!overlayCover) return;

const t = overlayCover.querySelector('#fyptt_shorts_cover_text');

if (t) t.textContent = txt;

overlayCover.style.display = 'flex';

}

function hideCover() {

if (!overlayCover) return;

overlayCover.style.display = 'none';

}

function updateCoverSize() {

if (!overlayCover || !overlayFrame) return;

const r = overlayFrame.getBoundingClientRect();

overlayCover.style.setProperty('--frame-w', `${Math.round(r.width)}px`);

overlayCover.style.setProperty('--frame-h', `${Math.round(r.height)}px`);

}

function injectFillCSS(doc) {

if (!doc || !doc.head) return;

const STYLE_ID = 'fyptt_shorts_fillcss_v620';

let style = doc.getElementById(STYLE_ID);

if (!style) {

style = doc.createElement('style');

style.id = STYLE_ID;

doc.head.appendChild(style);

}

style.textContent = `

html, body { margin:0 !important; padding:0 !important; width:100% !important; height:100% !important; overflow:hidden !important; background:#000 !important; }

* { box-sizing: border-box !important; }

.video-js, .plyr, .jwplayer, .vjs-video-container,

.plyr__video-wrapper, .plyr__video-embed,

.vjs-fluid, .vjs-16-9, .vjs-4-3 {

width:100% !important; height:100% !important;

max-width:none !important; max-height:none !important;

}

video, .vjs-tech {

width:100% !important; height:100% !important;

max-width:none !important; max-height:none !important;

object-fit: var(--fyptt_fit, cover) !important;

background:#000 !important;

}

.vjs-fluid, .vjs-fluid:not(.vjs-audio-only-mode) { padding-top: 0 !important; }

.vjs-fluid .vjs-tech { position:absolute !important; inset:0 !important; }

.jwplayer { position: absolute !important; inset: 0 !important; }

.jwplayer .jw-wrapper,

.jwplayer .jw-overlays,

.jwplayer .jw-media,

.jwplayer .jw-preview,

.jwplayer .jw-stage {

position: absolute !important;

inset: 0 !important;

width:100% !important; height:100% !important;

max-width:none !important; max-height:none !important;

}

.jwplayer .jw-aspect { display: none !important; padding-top: 0 !important; height: 0 !important; }

.jwplayer video, video.jw-video {

width:100% !important; height:100% !important;

object-fit: var(--fyptt_fit, cover) !important;

}

`;

try { doc.documentElement.style.setProperty('--fyptt_fit', fitMode); } catch {}

}

function getActiveVideoFromFrame(frame) {

if (!frame) return null;

let doc;

try { doc = frame.contentDocument; } catch { return null; }

if (!doc) return null;

return pickLargest(Array.from(doc.querySelectorAll('video')));

}

function seekInActiveFrame(deltaSeconds) {

const frame = activeControlFrame || overlayFrame;

const v = getActiveVideoFromFrame(frame);

if (!v) return false;

try {

const cur = Number.isFinite(v.currentTime) ? v.currentTime : 0;

const dur = Number.isFinite(v.duration) ? v.duration : Infinity;

v.currentTime = Math.min(dur, Math.max(0, cur + deltaSeconds));

return true;

} catch { return false; }

}

function applyMuteToActiveVideo() {

const frame = activeControlFrame || overlayFrame;

const v = getActiveVideoFromFrame(frame);

if (!v) return;

try {

v.muted = userMuted;

if (!userMuted) v.volume = 1;

} catch {}

}

function togglePlayPauseActive() {

const frame = activeControlFrame || overlayFrame;

const v = getActiveVideoFromFrame(frame);

if (!v) return;

try {

if (v.paused) v.play?.().catch(();

else v.pause?.();

} catch {}

}

function setFrameFromVideoAspect(aspect) {

if (!Number.isFinite(aspect) || aspect <= 0) return;

const a = clamp(aspect, 0.45, 3.0);

const wide = a >= WIDE_ENOUGH;

fitMode = wide ? 'contain' : 'cover';

frameAspect = wide ? clamp(a, PHONE_ASPECT, FRAME_ASPECT_CAP) : PHONE_ASPECT;

sizeOverlayIframe();

updateCoverSize();

try { overlayFrame?.contentDocument?.documentElement?.style?.setProperty('--fyptt_fit', fitMode); } catch {}

try { activeControlFrame?.contentDocument?.documentElement?.style?.setProperty('--fyptt_fit', fitMode); } catch {}

}

function collectPostUrls() {

const anchors = Array.from(document.querySelectorAll('a[href]'));

const seen = new Set();

const out = [];

for (const a of anchors) {

let u;

try { u = new URL(a.href); } catch { continue; }

if (u.origin !== ORIGIN) continue;

if (!/^\/\d+\/.+/i.test(u.pathname)) continue;

if (!seen.has(u.href)) { seen.add(u.href); out.push(u.href); }

}

return out;

}

function sizeOverlayIframe() {

if (!overlayFrame) return;

const maxW = Math.round(window.innerWidth * FRAME_MARGIN);

const maxH = Math.round(window.innerHeight * PHONE_MAX_H);

let w = maxW;

let h = Math.round(w / frameAspect);

if (h > maxH) {

h = maxH;

w = Math.round(h * frameAspect);

}

overlayFrame.style.width = `${w}px`;

overlayFrame.style.height = `${h}px`;

}

function updateCounter() {

const el = overlay?.querySelector('#fyptt_shorts_counter');

if (!el) return;

el.textContent = urls.length && index >= 0 ? `${index + 1}/${urls.length}` : `0/0`;

}

function renderBadge() {

if (!badge) {

badge = document.createElement('div');

badge.id = 'fyptt_shorts_badge';

document.body.appendChild(badge);

}

badge.textContent = `Shorts: ${shortsEnabled ? 'ON' : 'OFF'} (press S)`;

badge.style.opacity = shortsEnabled ? '1' : '0.6';

}

function ensureOverlay() {

if (overlay) return;

overlay = document.createElement('div');

overlay.id = 'fyptt_shorts_overlay';

overlay.tabIndex = 0;

overlay.innerHTML = `

<div id="fyptt_shorts_header">

<div><b>Shorts Mode</b> <span id="fyptt_shorts_watermark">Arvagnar</span></div>

<div id="fyptt_shorts_counter">–</div>

<div>↑/↓ • Wheel • ←/→ • Space • Auto • M • ESC</div>

</div>

<div id="fyptt_shorts_cover">

<div id="fyptt_shorts_spinner"></div>

<div id="fyptt_shorts_cover_text">Loading…</div>

</div>

<iframe id="fyptt_shorts_iframe" allow="autoplay; fullscreen; picture-in-picture" referrerpolicy="strict-origin-when-cross-origin"></iframe>

`;

document.body.appendChild(overlay);

overlayFrame = overlay.querySelector('#fyptt_shorts_iframe');

overlayCover = overlay.querySelector('#fyptt_shorts_cover');

const style = document.createElement('style');

style.textContent = `

#fyptt_shorts_badge{

position: fixed; z-index: 999999; right: 14px; bottom: 14px;

background: rgba(0,0,0,0.72); color: #fff; padding: 8px 10px;

border-radius: 10px; font: 12px/1.2 system-ui, -apple-system, Segoe UI, Roboto, Arial;

user-select: none;

}

#fyptt_shorts_overlay{

position: fixed; z-index: 999998; inset: 0;

display: none; align-items: center; justify-content: center;

background: rgba(0,0,0,0.92);

outline: none;

}

#fyptt_shorts_header{

position: absolute; top: 12px; left: 12px; right: 12px;

display: flex; justify-content: space-between; align-items: center; gap: 12px;

color: #fff; font: 13px/1.2 system-ui, -apple-system, Segoe UI, Roboto, Arial;

opacity: 0.9; pointer-events: none;

}

#fyptt_shorts_watermark{

font-weight: 600;

opacity: 0.55;

margin-left: 8px;

letter-spacing: 0.3px;

}

#fyptt_shorts_iframe{

border: 0; border-radius: 14px; background: #000;

box-shadow: 0 12px 40px rgba(0,0,0,0.55);

display: block;

}

#fyptt_shorts_cover{

position: absolute;

top: 50%; left: 50%;

transform: translate(-50%, -50%);

width: var(--frame-w, 60vw);

height: var(--frame-h, 80vh);

border-radius: 14px;

background: #000;

box-shadow: 0 12px 40px rgba(0,0,0,0.55);

display: none;

align-items: center;

justify-content: center;

flex-direction: column;

gap: 12px;

z-index: 999999;

pointer-events: auto;

}

#fyptt_shorts_spinner{

width: 34px; height: 34px;

border-radius: 999px;

border: 3px solid rgba(255,255,255,0.25);

border-top-color: rgba(255,255,255,0.95);

animation: fypttspin 0.9s linear infinite;

}

#fyptt_shorts_cover_text{

color: rgba(255,255,255,0.92);

font: 13px/1.2 system-ui, -apple-system, Segoe UI, Roboto, Arial;

}

u/keyframes fypttspin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

`;

document.head.appendChild(style);

overlay.addEventListener('mousedown', (e) => {

if (e.target === overlay) closeOverlay();

});

overlayFrame.addEventListener('load', () => {

cleanupAllBindings();

activeControlFrame = overlayFrame;

try {

const doc = overlayFrame.contentDocument;

if (doc) injectFillCSS(doc);

} catch {}

preparePlayerInOverlayFrame(overlayFrame);

updateCounter();

try { overlay.focus({ preventScroll: true }); } catch { try { overlay.focus(); } catch {} }

});

overlay.addEventListener('wheel', (e) => {

if (overlay.style.display === 'none') return;

const now = Date.now();

if (now < wheelCooldownUntil) return;

if (Math.abs(e.deltaY) < 15) return;

e.preventDefault();

wheelCooldownUntil = now + 650;

navigate(e.deltaY > 0 ? +1 : -1);

}, { passive: false });

window.addEventListener('keydown', onOverlayKeys, true);

overlay.addEventListener('keydown', onOverlayKeys, true);

window.addEventListener('resize', () => {

sizeOverlayIframe();

updateCoverSize();

});

sizeOverlayIframe();

updateCoverSize();

if (!coverSizerTimer) coverSizerTimer = setInterval(updateCoverSize, 250);

renderBadge();

}

async function resolveInternalPlayerSrc(postUrl) {

try {

const r = await fetch(postUrl, { credentials: 'include' });

if (!r.ok) return null;

const html = await r.text();

const doc = new DOMParser().parseFromString(html, 'text/html');

const ifr = Array.from(doc.querySelectorAll('iframe[src]')).find(x => {

const src = x.getAttribute('src') || '';

if (!src) return false;

if (/rokt\.com/i.test(src)) return false;

return PLAYER_IFRAME_RE.test(src);

});

if (!ifr) return null;

const src = ifr.getAttribute('src');

if (!src) return null;

return new URL(src, ORIGIN).href;

} catch {

return null;

}

}

async function loadCurrent() {

if (!overlay || overlay.style.display === 'none') return;

if (index < 0 || index >= urls.length) return;

const mySeq = ++loadSeq;

frameAspect = PHONE_ASPECT;

fitMode = 'cover';

sizeOverlayIframe();

updateCoverSize();

showCover('Loading…');

const postUrl = urls[index];

const internal = await resolveInternalPlayerSrc(postUrl);

if (mySeq !== loadSeq) return;

overlayFrame.src = internal || postUrl;

}

function openOverlay(startUrl) {

urls = collectPostUrls();

urls = [startUrl, ...urls.filter(u => u !== startUrl)];

index = 0;

ensureOverlay();

overlay.style.display = 'flex';

document.documentElement.style.overflow = 'hidden';

updateCounter();

try { overlay.focus({ preventScroll: true }); } catch { try { overlay.focus(); } catch {} }

loadCurrent();

}

function closeOverlay() {

if (!overlay) return;

cleanupAllBindings();

overlay.style.display = 'none';

overlayFrame.src = 'about:blank';

document.documentElement.style.overflow = '';

urls = [];

index = -1;

activeControlFrame = null;

frameAspect = PHONE_ASPECT;

fitMode = 'cover';

sizeOverlayIframe();

updateCoverSize();

hideCover();

updateCounter();

}

function navigate(dir) {

if (!overlay || overlay.style.display === 'none') return;

const next = index + dir;

if (next < 0 || next >= urls.length) return;

index = next;

updateCounter();

loadCurrent();

}

function onOverlayKeys(e) {

if (!overlay || overlay.style.display === 'none') return;

if (isTypingContext(document.activeElement)) return;

if (e.repeat) return;

if (e.key === 'Escape') { e.preventDefault(); closeOverlay(); return; }

if (e.key === 'ArrowDown') { e.preventDefault(); navigate(+1); return; }

if (e.key === 'ArrowUp') { e.preventDefault(); navigate(-1); return; }

if (e.key === 'ArrowLeft') { e.preventDefault(); seekInActiveFrame(-SEEK_SECONDS); return; }

if (e.key === 'ArrowRight') { e.preventDefault(); seekInActiveFrame(+SEEK_SECONDS); return; }

if (isSpaceKey(e)) {

e.preventDefault();

e.stopPropagation();

if (e.stopImmediatePropagation) e.stopImmediatePropagation();

togglePlayPauseActive();

return;

}

if (e.key.toLowerCase() === 'm') {

e.preventDefault();

userMuted = !userMuted;

applyMuteToActiveVideo();

return;

}

}

function findInternalPlayerIframe(doc) {

const candidates = Array.from(doc.querySelectorAll('iframe[src]'));

return candidates.find(ifr => {

const src = ifr.getAttribute('src') || '';

if (!src) return false;

if (/rokt\.com/i.test(src)) return false;

return PLAYER_IFRAME_RE.test(src) || PLAYER_IFRAME_RE.test(ifr.src || '');

}) || doc.querySelector('iframe.arve-iframe');

}

function preparePlayerInOverlayFrame(frameEl) {

let doc, href = '';

try {

doc = frameEl.contentDocument;

href = frameEl.contentWindow?.location?.href || '';

} catch { return; }

if (!doc || !doc.body) return;

injectFillCSS(doc);

const alreadyInternal = PLAYER_IFRAME_RE.test(href);

if (!alreadyInternal) {

const internal = findInternalPlayerIframe(doc);

if (internal?.src) {

const src = internal.src;

doc.body.innerHTML = '';

const wrap = doc.createElement('div');

wrap.style.cssText = 'position:fixed; inset:0; background:#000;';

const ifr = doc.createElement('iframe');

ifr.src = src;

ifr.referrerPolicy = 'strict-origin-when-cross-origin';

ifr.allow = 'autoplay; fullscreen; picture-in-picture';

ifr.allowFullscreen = true;

ifr.style.cssText = 'position:absolute; inset:0; width:100%; height:100%; border:0; background:#000;';

wrap.appendChild(ifr);

doc.body.appendChild(wrap);

const onLoad = () => bindControlsToVideoContext(ifr);

ifr.addEventListener('load', onLoad);

cleanupFns.push(() => ifr.removeEventListener('load', onLoad));

activeControlFrame = ifr;

return;

}

}

const vids = Array.from(doc.querySelectorAll('video'));

const mainVideo = pickLargest(vids);

if (!mainVideo) {

const mo = new MutationObserver(() => {

const v2 = pickLargest(Array.from(doc.querySelectorAll('video')));

if (v2) { mo.disconnect(); preparePlayerInOverlayFrame(frameEl); }

});

mo.observe(doc.documentElement, { childList: true, subtree: true });

cleanupFns.push(() => { try { mo.disconnect(); } catch {} });

return;

}

const root =

mainVideo.closest('.video-js') ||

mainVideo.closest('.plyr') ||

mainVideo.closest('.jwplayer') ||

mainVideo.closest('.vjs-video-container') ||

mainVideo;

try { root.remove(); } catch {}

doc.body.innerHTML = '';

const wrap = doc.createElement('div');

wrap.style.cssText = 'position:fixed; inset:0; background:#000;';

root.style.position = 'absolute';

root.style.inset = '0';

root.style.width = '100%';

root.style.height = '100%';

root.style.maxWidth = 'none';

root.style.maxHeight = 'none';

root.style.margin = '0';

root.style.paddingTop = '0';

mainVideo.style.width = '100%';

mainVideo.style.height = '100%';

mainVideo.style.maxWidth = 'none';

mainVideo.style.maxHeight = 'none';

mainVideo.style.background = '#000';

wrap.appendChild(root);

doc.body.appendChild(wrap);

injectFillCSS(doc);

activeControlFrame = frameEl;

bindControlsToVideoContext(frameEl);

}

function setupRobustAutoNext(video, goNext) {

if (!video) return () => {};

let stopped = false;

let lastFire = 0;

let lastSrc = video.currentSrc || video.src || '';

const shouldFire = () => {

if (stopped) return false;

const now = Date.now();

if (now - lastFire < COOLDOWN_MS) return false;

const srcNow = video.currentSrc || video.src || '';

if (srcNow && srcNow !== lastSrc) {

lastSrc = srcNow;

lastFire = 0;

}

if (video.ended) return true;

const dur = video.duration;

const cur = video.currentTime;

if (Number.isFinite(dur) && dur > 0 && Number.isFinite(cur)) {

const remaining = dur - cur;

if (remaining <= END_EPSILON_SEC && cur > 0) return true;

}

return false;

};

const fire = () => {

if (!shouldFire()) return;

lastFire = Date.now();

goNext();

};

const onEnded = () => fire();

const onTimeUpdate = () => fire();

const onPause = () => {

const dur = video.duration;

const cur = video.currentTime;

if (Number.isFinite(dur) && dur > 0 && Number.isFinite(cur)) {

const remaining = dur - cur;

if (remaining <= END_EPSILON_SEC) fire();

}

};

const poll = setInterval(() => {

if (stopped) return;

if (shouldFire()) fire();

}, END_POLL_MS);

try { video.loop = false; video.removeAttribute('loop'); } catch {}

video.addEventListener('ended', onEnded);

video.addEventListener('timeupdate', onTimeUpdate);

video.addEventListener('pause', onPause);

return () => {

stopped = true;

clearInterval(poll);

try {

video.removeEventListener('ended', onEnded);

video.removeEventListener('timeupdate', onTimeUpdate);

video.removeEventListener('pause', onPause);

} catch {}

};

}

function bindControlsToVideoContext(targetFrame) {

let win, doc;

try { win = targetFrame.contentWindow; doc = targetFrame.contentDocument; } catch { return; }

if (!win || !doc) return;

activeControlFrame = targetFrame;

injectFillCSS(doc);

const getActiveVideo = () => pickLargest(Array.from(doc.querySelectorAll('video')));

const tryStartPlayback = (v) => {

if (!v) return;

const updateAspect = () => {

const vw = v.videoWidth;

const vh = v.videoHeight;

if (vw && vh) setFrameFromVideoAspect(vw / vh);

};

const readyOnce = () => hideCover();

v.addEventListener('loadedmetadata', updateAspect, { once: true });

v.addEventListener('playing', readyOnce, { once: true });

v.addEventListener('loadeddata', readyOnce, { once: true });

setTimeout(updateAspect, 350);

setTimeout(() => { if (overlay && overlay.style.display !== 'none') hideCover(); }, 2500);

try { v.playsInline = true; v.setAttribute('playsinline', ''); } catch {}

try {

if (userMuted) { v.muted = true; }

else if (DEFAULT_AUDIO_ON) { v.muted = false; v.volume = 1; }

} catch {}

try { v.play?.().catch((); } catch {}

if (DEFAULT_AUDIO_ON && !userMuted) {

const unmute = () => { try { v.muted = false; v.volume = 1; } catch {} };

v.addEventListener('playing', () => setTimeout(unmute, 50), { once: true });

setTimeout(unmute, 900);

}

try { doc.documentElement.style.setProperty('--fyptt_fit', fitMode); } catch {}

};

let video = getActiveVideo();

if (video) tryStartPlayback(video);

else showCover('Loading…');

let stopAutoNext = () => {};

let lastEndedGate = 0;

const goNext = () => {

const now = Date.now();

if (now - lastEndedGate < COOLDOWN_MS) return;

lastEndedGate = now;

navigate(+1);

};

if (video) stopAutoNext = setupRobustAutoNext(video, goNext);

const mo = new MutationObserver(() => {

const v2 = getActiveVideo();

if (v2 && v2 !== video) {

try { stopAutoNext(); } catch {}

video = v2;

showCover('Loading…');

tryStartPlayback(video);

stopAutoNext = setupRobustAutoNext(video, goNext);

}

});

mo.observe(doc.documentElement, { childList: true, subtree: true });

cleanupFns.push(() => { try { mo.disconnect(); } catch {} });

cleanupFns.push(() => { try { stopAutoNext(); } catch {} });

const onKey = (e) => {

if (!overlay || overlay.style.display === 'none') return;

if (e.repeat) return;

if (e.key === 'Escape') { e.preventDefault(); closeOverlay(); return; }

if (e.key === 'ArrowDown') { e.preventDefault(); navigate(+1); return; }

if (e.key === 'ArrowUp') { e.preventDefault(); navigate(-1); return; }

if (isSpaceKey(e)) {

e.preventDefault();

e.stopPropagation();

if (e.stopImmediatePropagation) e.stopImmediatePropagation();

const v = getActiveVideo();

if (!v) return;

try { if (v.paused) v.play?.().catch((); else v.pause?.(); } catch {}

return;

}

if (isTypingContext(doc.activeElement)) return;

if (e.key === 'ArrowLeft') { e.preventDefault(); seekInActiveFrame(-SEEK_SECONDS); return; }

if (e.key === 'ArrowRight') { e.preventDefault(); seekInActiveFrame(+SEEK_SECONDS); return; }

const v = getActiveVideo();

if (!v) return;

if (e.key.toLowerCase() === 'm') {

e.preventDefault();

userMuted = !userMuted;

try { v.muted = userMuted; if (!userMuted) v.volume = 1; } catch {}

return;

}

};

win.addEventListener('keydown', onKey, true);

doc.addEventListener('keydown', onKey, true);

win.addEventListener('keypress', onKey, true);

doc.addEventListener('keypress', onKey, true);

cleanupFns.push(() => {

try { win.removeEventListener('keydown', onKey, true); } catch {}

try { doc.removeEventListener('keydown', onKey, true); } catch {}

try { win.removeEventListener('keypress', onKey, true); } catch {}

try { doc.removeEventListener('keypress', onKey, true); } catch {}

});

const onWheel = (e) => {

if (!overlay || overlay.style.display === 'none') return;

const now = Date.now();

if (now < wheelCooldownUntil) return;

if (Math.abs(e.deltaY) < 15) return;

e.preventDefault();

wheelCooldownUntil = now + 650;

navigate(e.deltaY > 0 ? +1 : -1);

};

win.addEventListener('wheel', onWheel, { passive: false });

cleanupFns.push(() => { try { win.removeEventListener('wheel', onWheel, { passive: false }); } catch {} });

try { overlay.focus({ preventScroll: true }); } catch { try { overlay.focus(); } catch {} }

}

window.addEventListener('keydown', (e) => {

if (isTypingContext(document.activeElement)) return;

if (e.repeat) return;

if (e.key.toLowerCase() === 's') {

shortsEnabled = !shortsEnabled;

setShortsEnabled(shortsEnabled);

renderBadge();

}

}, true);

document.addEventListener('click', (e) => {

if (!shortsEnabled) return;

if (e.button !== 0) return;

const a = e.target?.closest?.('a[href]');

if (!a) return;

let u;

try { u = new URL(a.href); } catch { return; }

if (u.origin !== ORIGIN) return;

if (!/^\/\d+\/.+/i.test(u.pathname)) return;

e.preventDefault();

e.stopPropagation();

if (e.stopImmediatePropagation) e.stopImmediatePropagation();

openOverlay(u.href);

}, true);

ensureOverlay();

})();


r/userscripts • • Feb 21 '26

I made a Tampermonkey script that removes annoying YouTube @ (At) signs on people's usernames in comments

0 Upvotes
// ==UserScript==
// @name         Youtube At Remover
// @namespace    https://www.youtube.com
// @version      2026-02-18
// @description  Remove annoying @ (At) in youtube comments usernames
// @author       Me
// @match        https://www.youtube.com/*
// @grant        none
// ==/UserScript==

function Init()
{
    const target = document.body;
    const config = { attributes: false, childList: true, subtree: true };
    const observer = new MutationObserver(Callback);
    observer.observe(target, config);
}

Init();

function Callback(mutation_list, observer)
{
	for(const mutation of mutation_list)
	{
		if(mutation.type === "childList")
		{
			var usernames = document.querySelectorAll("#author-text");

			for(let un of usernames)
			{
				let uname = un.children[0].textContent;

				let idx = uname.indexOf("@");
				if(idx != -1)
				{
					un.children[0].textContent = uname.substring(0, idx) + uname.substring(idx + 1);
				}
			}
		}
	}
}

r/userscripts • • Aug 03 '26

Bro stop using paid instagram automation tools.

Thumbnail github.com
0 Upvotes

I have built and open-sourced it for y'all.


r/userscripts • • Aug 01 '22

Is this userscript safe?, does it contain any shady lines?

Thumbnail
greasyfork.org
0 Upvotes

r/userscripts • • Jul 29 '22

Script to keep the sidebar in reddit always on

0 Upvotes

redesigned reddit


r/userscripts • • Apr 06 '24

I asked Phind to write me a userscript that will remove the "&si=" section from YouTube URLs. Will this work?

0 Upvotes

Here's a link to my query: https://www.phind.com/search?cache=svggur5jny3b8drhb7ymka0x

Here's the script in question (it's the fourth script down in the link):

// ==UserScript==
// @name         YouTube Link Cleaner
// @version      1.0
// @description Removes source identifier from all YouTube links containing "&si=" or "si="
// @author       Your Name
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to clean YouTube URLs
    function cleanYouTubeURL(url) {
        // Regular expression to match YouTube video IDs
        const videoIdRegex = /(?:v=|\/)([A-Za-z0-9_-]{11})/;
        const match = url.match(videoIdRegex);
        if (match) {
            // Construct a clean URL using the video ID
            return `https://www.youtube.com/watch?v=${match[1]}`;
        }
        return url; // Return the original URL if no video ID is found
    }

    // Function to process all links on the page
    function processLinks() {
        const links = document.querySelectorAll('a[href]');
        links.forEach(link => {
            const href = link.getAttribute('href');
            if (href && href.includes('youtube.com') && (href.includes('&si=') || href.includes('si='))) {
                link.setAttribute('href', cleanYouTubeURL(href));
            }
        });
    }

    // Run the link processing function on page load
    processLinks();

    // Listen for changes to the DOM to handle dynamically loaded content
    const observer = new MutationObserver(processLinks);
    observer.observe(document.body, { childList: true, subtree: true });
})();

EDIT: Decided to test it myself. Needed to remove the // @match *://*.youtube.com/* line from the header to get it working on Reddit. Seems to work well!

I'm also using this script, which is supposed to remove the tracking parameter, but it doesn't actually change the URL on the page: https://greasyfork.org/en/scripts/482977-remove-youtube-tracking-parameters-and-convert-share-links

As well, I'm using this one to convert YouTube Shorts links: https://greasyfork.org/en/scripts/474490-unshort-youtube

Hopefully these don't all conflict.

EDIT2: Clarification.

EDIT3: Updated the script somewhat.


r/userscripts • • Dec 03 '25

I made a custom userscript just to replace "bedrock" with "bugrock" among other things

0 Upvotes

Yeah

For example if you guys comment ", also im a total idiot just btw, toilet is playing bugrock edition on twitter" I will see "sk*b*di toilet is playing bugrock edition on X"

because twitter is now X, bugrock is now buggy, and , also im a total idiot just btw, toilet should be illegal


r/userscripts • • 9d ago

Would you use a tool that lets you bulk-delete X posts/likes with advanced filters and local JSON backups?

Thumbnail
reddit.com
0 Upvotes

r/userscripts • • Apr 19 '25

Anyone using AI agents for developing Userscripts? I would like some tips!

3 Upvotes

Do agents or just AI chatbots help a lot in creating a UserScript? Please suggest some workflow.


r/userscripts • • Aug 12 '26

My wife never clicked the links I sent her. So I built a Chrome extension to fix it.

3 Upvotes

I send my wife random links all the time. But instead of clicking them, her reply is almost always: "What is this?"

Honestly, it’s a bit of a buzzkill. But when we talked about it, she made a fair point: a raw URL with zero context feels like homework. You don't know if it's a 10-minute read or a jump scare. Nobody likes naked links.

I tried manually copying page titles and pasting URLs, but as a frontend dev, I hate repetitive manual tasks. So I wrote a script to fix my own communication flow.

It’s calledCopy Page Title and URL Pro.

Just hit Ctrl+Shift+P (or Cmd+Shift+P), and it instantly copies the page title and a clean URL to your clipboard. It automatically strips out all that ugly ?utm_ tracking garbage.

Since I live in Jira and Notion, I also baked in Markdown/HTML support. You can even highlight a quote, hit a shortcut, and bundle the quote + title + link in one go.

It’s completely free, open-source, and runs 100% locally with zero tracking.

Best of all: my wife actually clicks my links now.

If you’re tired of mystery URLs, give it a try. Would love to hear your feedback!


r/userscripts • • Oct 23 '25

youtube-usmode: A Tampermonkey userscript that gives YouTube a U.S.-style look by hiding regional country codes under the logo.

1 Upvotes

YouTube US Mode (Hide Region Label)

A lightweight Tampermonkey userscript that hides YouTube's regional country code (like “PH”, “IN”, etc.) to make the site appear cosmetically identical to the U.S. version.

⚠️ Note: This script is primarily for personal use. It is considered stable and unlikely to need updates. If YouTube changes its top bar layout, updates may be released.


📷 Before vs After

Before vs After


✨ Features

  • Removes the small country code label under the YouTube logo (e.g. “PH”, “IN”).

  • Mimics the visual style of YouTube's U.S. default mode.

  • Lightweight and auto-applies whenever YouTube loads.

  • Keeps all other regional functionality intact — just cosmetic.


🧠 How It Works

The script continuously looks for the #country-code element on YouTube and hides it using a lightweight DOM observer.

const el = document.querySelector('span#country-code');
if (el && el.style.display !== 'none') el.style.display = 'none';

⚙️ Installation

  1. Install Tampermonkey for your browser:

  2. Download or open the userscript: youtube-us-mode.user.js

  3. Click Install in Tampermonkey.

  4. Reload YouTube — the country code under the logo will now be hidden, giving the site a U.S. look.


🔗 Links


🤖 Transparency & Credits

This README and accompanying documentation were written entirely by ChatGPT (GPT-5).

  • The userscript code was authored by ChatGPT (GPT-5).

  • The userscript code was published by Zappingsbrew.

  • ChatGPT generated the README structure, sections, formatting, and descriptive text.

  • This userscript is purely cosmetic and does not modify YouTube functionality or collect any personal data.


🧾 License

This project is licensed under the MIT License.

© 2025 Zappingsbrew


r/userscripts • • Apr 09 '26

Greasyfork, pc, trump, remove

Thumbnail greasyfork.org
1 Upvotes

Do you like reddit but are sick of seeing Trump or Trump or Trump? Do you wish you could go back in time and not see this guy on every other post? Do you want to see what else is going on in the world besides a Trump and a Trump? Guess what, I have a script for you! This script blocks all post that have the word Donald, and or Trump. Its like seeing a new world without a 80 year old dude all up in your feed. https://greasyfork.org/en/scripts/569891-remove-trump-articles


r/userscripts • • Jun 21 '25

Anyone can please suggest me few finance services related templates for building static webpage as I not good at ui!

0 Upvotes

r/userscripts • • May 28 '26

Userscript to block youtube keyboard shortcuts

0 Upvotes

While watching youtube I usually seek using the left and right arrow key, but sometimes that damn end key gets mistakenly pressed and suddenly the video ends.
I mean who in the right mind would want a keyboard shortcut to end a video (unless you are trying to complete a training video (but why yt!?!?))

anyways... I created (*generated..ahem!*) a script that you can use in tampermonkey/violentmonkey to block certain keys

// ==UserScript==
//          Disable YouTube Shortcut Keys
//     http://tampermonkey.net
//       1.0
//   Blocks only the listed key shortcut on YouTube
//        You
//         https://www.youtube.com/*
//         none
//        document-start
// ==/UserScript==

(function() {
    'use strict';

    // ─── ADD YOUR BLOCKED KEYS HERE ───────────────────────────────────────
    // Just add the name of the key inside quotes, separated by commas.
    // Examples: 'End', 'Home', 'PageUp', 'PageDown', 'ArrowUp'
    const blockedKeys = [
        'End',
        'Home'
    ];
    // ───────────────────────────────────────────────────────────────────────

    window.addEventListener('keydown', function(e) {
        // Check if the pressed key is in your blocked list
        if (blockedKeys.includes(e.key)) {
            // Stop YouTube from seeing the keypress
            e.stopImmediatePropagation();
            e.preventDefault();
        }
    }, true);
})();

r/userscripts • • Sep 06 '26

Userscript/tool to export claudeCode/claude browser etc to md/txt

Thumbnail reddit.com
0 Upvotes

r/userscripts • • 18d ago

I have built a floating toolbar for Gemini, Claude, Chatgpt & Grok supporting bulk chat delete,token counter,screenshot, export chat, health remainder,theme and many more.

Thumbnail
reddit.com
0 Upvotes

r/userscripts • • Oct 29 '21

[Firefox Android] JS script to auto-rotate display on every fucking video of every fucking player?

0 Upvotes

Something like if extension is mp4, ts, mpd, m3u8, mkv, wmv and resolution width > height, then auto-landscape during play and return to portrait after end. Because currently not all videos auto-rotate, ancensored.com for example is where some videos still at portrait when played at fullscreen.

Is there any Adguard js script for this? Someone have any idea how to code it?


r/userscripts • • May 25 '20

Make "logged out" reddit looks like "logged in" userscript. Help to keep my privacy.

0 Upvotes

Reddit conversation are shit by default (shitty mods circlejerking etc) so I will never post again but I want to comforatbly read useful threads and don't keep cookies for this shitty community. Help me.


r/userscripts • • Oct 21 '23

[Request] Looking for a script that removes ads on Youtube feed

0 Upvotes

I want a script to remove these kind of ads. Thanks.


r/userscripts • • Mar 19 '14

Userscripts for Safari 7?

0 Upvotes

I've done some research and I cannot find anything to make this happen. I've seen NinjaKit but it hasn't been uploaded in 2 years. Are there any alternatives?


r/userscripts • • Feb 02 '26

Linux Gaming Setup Script

0 Upvotes

I created this script to transform any standard Linux distribution into a 'gaming distro.' It currently supports most major Arch-based distributions, Ubuntu, Zorin, Mint, Fedora, and openSUSE Tumbleweed. If you would like to take a look at it, you can visit the GitHub repository: https://github.com/softwaresocialist/TurboTux

How to try it out:

1. Clone the repository

git clone https://github.com/softwaresocialist/TurboTux.git
cd TurboTux

2. Run the script

chmod +x TurboTux.sh
./TurboTux.sh

r/userscripts • • Oct 09 '22

ohio isnt real

0 Upvotes

ohio isnt real ohio isnt real ohio isnt real ohio isnt real ohio isnt real ohio isnt real ohio isnt real ohio isnt real ohio isnt real ohio isnt real


r/userscripts • • Sep 19 '25

The Essential Tool for Userscript Developers - Temper Server

4 Upvotes

🚀 Tired of manually reinstalling your userscripts every time you make a change?

Temper Server is built for userscript developers who want a smoother, faster workflow. Instead of juggling files and refreshing manually, you can:

  • ⚡ Serve scripts locally – test instantly without uploading or re-installing.

  • 📈 Auto-increment versions – let your userscript manager detect updates automatically.

  • 🔄 One-click sync – update your scripts in Tampermonkey, Violentmonkey, or Greasemonkey with a single click.

  • 🛠️ Dev-friendly workflow – spend less time on setup, more time coding.

Whether you’re creating a small personal script or maintaining multiple projects, Temper Server makes development reliable, fast, and frustration-free.

👉 If you build with userscripts, Temper Server should be part of your toolkit.

ProjectLink: https://github.com/ThoriqFathurrozi/TemperServe


r/userscripts • • Sep 21 '25

Buying Website domain for website?

1 Upvotes

Hi, redditors Need a small suggestion. I am working on a website and I want to buy a domain for it. Can anyone suggest from where I should buy the domain so that it will be affordable plus reliable? Also you can share your experiences if you have bought a domain and how it worked for you so that it will be easier for me to decide.

domain #website