Greasy Fork

Greasy Fork is available in English.

智慧树PPT下载

智慧树下载脚本,希望能帮到大家

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         智慧树PPT下载
// @namespace    http://tampermonkey.net/
// @version      0.1.0
// @author       Wwhds
// @description  智慧树下载脚本,希望能帮到大家
// @match        https://hike-doc-online-h5.zhihuishu.com/alweb.html?*
// @icon         https://wwhds-markdown-image.oss-cn-beijing.aliyuncs.com/Markdown%E4%BD%BF%E7%94%A8/w.jpg
// @grant        none
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/1.10.1/jquery.min.js
// @license      MIT
// @run-at       document-end
// ==/UserScript==


(function ($) {
    $(function () {
        console.log("当前URL: " + window.document.URL)
        // 获取网页内容
        // PPTX资源所在元素
        function getPPTXSource() {
            // 使用window.document获取当前网页内容
            var divs = window.document
            var pptxUrl = divs.URL
            var regex = /WOPISrc=(.*)/;
            var match = pptxUrl.match(regex);
            console.log("资源地址: " + pptxUrl)
            if (match) {
                console.log(match[1]);
                fetch(match[1])
                    .then(response => response.blob())
                    .then(blob => {
                        // Create a new object URL for the blob
                        var url = match[1]
                        // Create a link and click it to start the download
                        var a = document.createElement('a');
                        a.href = url;
                        document.body.appendChild(a); // Required for Firefox
                        a.click();
                        a.remove();
                    })
                    .catch(e => console.error(e));
            } else {
                console.log("No match found.");
            }
        }

        if (window.document.URL.indexOf("ppt") != -1 && confirm("确定要下载PPT吗?")){
            getPPTXSource();
        }
    });
})(jQuery);