XNXX – Download button

add a download button on bottom right

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         XNXX – Download button
// @namespace    http://tampermonkey.net/
// @version      2026.03.1
// @description  add a download button on bottom right
// @author       Guile93
// @match        https://www.xnxx.com/*
// @match        https://player.xnxx.com/*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function () {
  'use strict';

  const BUTTON_ID = 'xnxx-download-btn';

function toAbsoluteUrl(u) {
  if (!u) return null;
  try { return new URL(u, location.href).href; } catch { return null; }
}

function findUrl() {
  if (window.html5player && typeof html5player.getVideoUrlHigh === "function") {
    const u = html5player.getVideoUrlHigh?.() || html5player.getVideoUrlLow?.();
    const abs = toAbsoluteUrl(u);
    if (abs) return abs;
  }

  const html = document.documentElement.innerHTML;

  const mHigh = html.match(/setVideoUrlHigh\(\s*'([^']+\.mp4[^']*)'\s*\)/i);
  if (mHigh?.[1]) return toAbsoluteUrl(mHigh[1]);

  const mLow = html.match(/setVideoUrlLow\(\s*'([^']+\.mp4[^']*)'\s*\)/i);
  if (mLow?.[1]) return toAbsoluteUrl(mLow[1]);

  const mJson = html.match(/"contentUrl"\s*:\s*"([^"]+\.mp4[^"]*)"/i);
  if (mJson?.[1]) return toAbsoluteUrl(mJson[1].replaceAll("\\/", "/"));

  const mAny = html.match(/(https?:\/\/[^\s"'<>]+\.mp4[^\s"'<>]*)/i);
  if (mAny?.[1]) return mAny[1];

  return null;
}

  const url = findUrl();
  if (!url) return;
  const btn = document.createElement('button');
  btn.id = BUTTON_ID;
  btn.textContent = '⬇ Download';
  btn.type = 'button';
  document.body.appendChild(btn);
  btn.onclick = () => window.open(url, '_blank');
  const style = document.createElement('style');
  style.textContent = `
    #${BUTTON_ID} {
      position: fixed;
      bottom: 20px;
      right: 20px;
      z-index: 999999;
      padding: 10px 20px;
      border: none;
      border-radius: 999px;
      background: linear-gradient(135deg, #b400ff, #8c00cc);
      color: #fff;
      font-size: 14px;
      font-weight: 600;
      font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
      cursor: pointer;
      box-shadow: 0 4px 14px rgba(0,0,0,.5);
      transition: transform .15s ease, box-shadow .15s ease, background .3s ease;
      backdrop-filter: blur(4px);
      filter: none !important;
      outline: none;
    }
    #${BUTTON_ID}:hover {
      transform: translateY(-2px) scale(1.05);
      background: linear-gradient(135deg, #c740ff, #a000f2);
      box-shadow: 0 8px 20px rgba(0,0,0,.6);
    }
    #${BUTTON_ID}:active {
      transform: translateY(0) scale(.97);
      box-shadow: 0 3px 10px rgba(0,0,0,.4);
    }
    #${BUTTON_ID}::before,
    #${BUTTON_ID}::after {
      display: none !important;
      content: none !important;
    }
  `;
  document.head.appendChild(style);
})();