Elearning Download

高雄科技大學 Elearning 檔案下載(114學年度修復版)

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Elearning Download
// @namespace    https://facaikotei.github.io/
// @version      6.0.1
// @description  高雄科技大學 Elearning 檔案下載(114學年度修復版)
// @author       (c)2025 facaikotei (c)2022 Juirmin
// @match        https://elearning.nkust.edu.tw/moocs/*
// @require      https://update.greasyfork.org/scripts/12228/175122/setMutationHandler.js
// @icon         https://elearning.nkust.edu.tw/moocs/assets/icons/PWA_icon_128.png
// @license      MIT
// @website      https://greasyfork.org/users/1305953
// ==/UserScript==

(function () {
    'use strict';

    setMutationHandler(document.querySelector('.cgust-main'), '.course-node__info', async (els) => {
        const courseNodeData = await (await fetch(`/api/v1/courses/${JSON.parse(sessionStorage.assignment).courseId}/node`)).json();
        const urlExtractor = item => [item.blank_url, ...item.items.flatMap(urlExtractor)];
        const urls = courseNodeData.data.items.flatMap(urlExtractor);
        els = [...new Set(els)];
        els.forEach((el, index) => {
            const url = urls[index % urls.length];
            if (url && !el.querySelector(`[href="${url}"]`)) {
                el.insertAdjacentHTML('beforeend', `<a target="_blank" href="${url}">下載</a>`);
            }
        });
    });
})();