Scribd Downloader Button

页面悬浮下拉菜单,一键选择不同站点下载Scribd文档

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        Scribd Downloader Button
// @name:en     Scribd Downloader Button (Open Download Link)
// @name:zh-CN  Scribd下载按钮(下拉选择站点)
// @description 页面悬浮下拉菜单,一键选择不同站点下载Scribd文档
// @description:en     Adds a button to the Scribd page to open a modified download link for easier access.
// @namespace   https://scribd.downloader.tips/
// @version     1.0.3
// @license MIT
// @author      Totapunk
// @match       https://*.scribd.com/document/*
// @grant       GM_addStyle
// @grant       GM_openInTab
// ==/UserScript==
(function() {
    'use strict';

    // 多语言按钮文字
    const translations = {
        es: "Descarga", en: "Download", zh: "下载", ja: "ダウンロード", ko: "다운로드"
    };
    function getTxt(){
        let lang = navigator.language.slice(0,2);
        return translations[lang] || translations['zh'];
    }

    // 下载站点配置
    const downloadSites = [
        {name:"站点1", url:"https://scribd.downloader.tips/document/{id}/{name}"},
        {name:"站点2", url:"https://scribd.vdownloaders.com/document/{id}/{name}"},
        {name:"站点3", url:"https://scribd.vpdfs.com/document/{id}/{name}"},
        {name:"站点4", url:"https://scribd.pdfdownloaders.com/document/{id}/{name}"},
        {name:"站点5", url:"https://docdownloader.com/init/scribd?url=https://www.scribd.com/document/{id}/{name}"}
    ];

    // 创建容器
    const wrap = document.createElement('div');
    wrap.style.position = 'fixed';
    wrap.style.top = '12px';
    wrap.style.right = '12px';
    wrap.style.zIndex = '99999';

    // 主按钮
    const mainBtn = document.createElement('button');
    mainBtn.innerText = getTxt() + " ▼";
    mainBtn.style.padding = "7px 14px";
    mainBtn.style.background = "#d1254c";
    mainBtn.style.color = "#fff";
    mainBtn.style.border = "none";
    mainBtn.style.borderRadius = "6px";
    mainBtn.style.cursor = "pointer";
    mainBtn.style.fontSize = "13px";

    // 下拉菜单
    const menu = document.createElement('div');
    menu.style.display = "none";
    menu.style.marginTop = "4px";
    menu.style.background = "#fff";
    menu.style.boxShadow = "0 2px 8px #0003";
    menu.style.borderRadius = "5px";
    menu.style.overflow = "hidden";

    // 填充下拉选项
    downloadSites.forEach(item=>{
        const opt = document.createElement('div');
        opt.innerText = item.name;
        opt.style.padding = "6px 12px";
        opt.style.cursor = "pointer";
        opt.style.fontSize = "12px";
        opt.style.whiteSpace = "nowrap";
        opt.onmouseover=()=>opt.style.background="#f0f0f0";
        opt.onmouseout=()=>opt.style.background="#fff";
        opt.onclick=()=>{
            const url = location.href;
            const reg = /\/document\/(\d+)\/([^\/]+)/;
            const res = url.match(reg);
            if(!res) return alert("链接解析失败");
            let finalUrl = item.url.replace("{id}",res[1]).replace("{name}",res[2]);
            window.open(finalUrl,"_blank");
            menu.style.display="none";
        };
        menu.appendChild(opt);
    });

    // 点击展开/收起
    mainBtn.onclick = (e)=>{
        e.stopPropagation();
        menu.style.display = menu.style.display==="none"?"block":"none";
    };

    // 点击页面任意处关闭下拉
    document.addEventListener("click",()=>menu.style.display="none");

    wrap.appendChild(mainBtn);
    wrap.appendChild(menu);
    document.body.appendChild(wrap);
})();