高科大教學平台PDF、教材下載

強制啟用PDF下載功能、一般教材添加備用載點,可解決iOS不支援下載、下載按鈕沒反應、檔案檔名亂碼

// ==UserScript==
// @name         高科大教學平台PDF、教材下載
// @namespace    https://facaikotei.github.io/
// @version      3
// @description  強制啟用PDF下載功能、一般教材添加備用載點,可解決iOS不支援下載、下載按鈕沒反應、檔案檔名亂碼
// @author       (c)2025 facaikotei
// @match        https://elearning.nkust.edu.tw/learn/*
// @icon         https://elearning.nkust.edu.tw/base/10001/door/tpl/icon.ico
// @grant        GM_addElement
// @grant        unsafeWindow
// @noframes
// @license      MIT
// @homepageURL  https://gf.qytechs.cn/scripts/496114
// ==/UserScript==

(function () {
    'use strict';

    let s_main = document.getElementById("s_main");
    s_main = s_main ? s_main.contentWindow : unsafeWindow;
    (s_main.frameElement || s_main).onload = function () {
        if (s_main.location.pathname == "/learn/path/viewPDF.php") {
            let download = s_main.document.getElementById("download");
            if (download.style.display == "none") {
                download.style.display = "block";
                download.onclick = function () {
                    open(s_main.DEFAULT_URL.replaceAll("%2F", "/"));
                };
            }
        }
        if (s_main.location.pathname == "/learn/path/download_preview.php") {
            let well = s_main.document.getElementsByClassName("well")[0];
            GM_addElement(well, "div", { style: "text-align: center;", });
            GM_addElement(well.lastElementChild, "a", {
                href:
                    "https://elearning.nkust.edu.tw/base/10001/course/" +
                    (s_main.prev_node_id || unsafeWindow.cid).match(/\d{8}/) +
                    "/content/" +
                    well.firstElementChild.innerText.replace(/ \([^\(]*$/, "")
                ,
                textContent: "備用載點",
                target: "_blank",
                download: "",
            });
        }
    };
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址