Scribd Free Reader

Open Scribd documents in full-screen (Embed Mode) with just a single click.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Scribd Free Reader
// @namespace    http://tampermonkey.net/
// @version      2.1
// @description  Open Scribd documents in full-screen (Embed Mode) with just a single click.
// @author       htrnguyen
// @match        https://www.scribd.com/document/*
// @match        https://www.scribd.com/doc/*
// @icon         https://raw.githubusercontent.com/htrnguyen/my-user-scripts/main/scripts/scribd-free-reader/logo.png
// @grant        none
// ==/UserScript==

(function () {
  "use strict";

  const ICON_READ = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"></path><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"></path></svg>`;

  const createButton = () => {
    if (document.getElementById("scribd-free-reader-btn")) return;

    const btn = document.createElement("button");
    btn.id = "scribd-free-reader-btn";
    btn.innerHTML = ICON_READ;
    btn.title = "Read Full Screen";

    Object.assign(btn.style, {
      position: "fixed",
      bottom: "20px",
      right: "20px",
      zIndex: "9999",
      width: "50px",
      height: "50px",
      borderRadius: "50%",
      border: "none",
      background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
      boxShadow: "0 4px 6px rgba(0,0,0,0.1)",
      cursor: "pointer",
      display: "flex",
      alignItems: "center",
      justifyContent: "center",
      transition: "transform 0.2s, box-shadow 0.2s",
    });

    btn.onmouseenter = () => {
      btn.style.transform = "translateY(-2px)";
      btn.style.boxShadow = "0 6px 8px rgba(0,0,0,0.2)";
    };
    btn.onmouseleave = () => {
      btn.style.transform = "translateY(0)";
      btn.style.boxShadow = "0 4px 6px rgba(0,0,0,0.1)";
    };

    btn.onclick = () => {
      const match = window.location.href.match(/(?:document|doc)\/(\d+)/);
      if (match && match[1]) {
        const embedUrl = `https://www.scribd.com/embeds/${match[1]}/content`;
        window.open(embedUrl, "_blank");
      } else {
        alert("Document ID not found.");
      }
    };

    document.body.appendChild(btn);
  };

  // Init
  createButton();

  // Handle SPA navigation
  let lastUrl = location.href;
  new MutationObserver(() => {
    if (location.href !== lastUrl) {
      lastUrl = location.href;
      setTimeout(createButton, 1000);
    }
  }).observe(document.body, { childList: true, subtree: true });
})();