司机会所直达下载页面

司机会所直达下载页面,无需点点点


    // ==UserScript==
    // @name         司机会所直达下载页面
    // @namespace    http://tampermonkey.net/
    // @version      0.2
    // @description  司机会所直达下载页面,无需点点点
    // @author       ClarkQAQ
    // @license      MIT
    // @match        http*://*/sj/*
    // @match        http*://*/wp-content/plugins/erphpdown/download.php?postid=*
    // @grant        none
    // ==/UserScript==
     
    (function () {
        'use strict';
        let autoDownload = false;
     
     
        let createDownload = (downloadBtn) => {
            let link = downloadBtn.href;
            if (link.indexOf("http") == -1) {
                GM_notification("下载链接不正确, 脚本无法直达!", "快车直达");
                return
            }
     
            if (autoDownload) location.href = link;
     
            let a = document.createElement("a");
            a.href = link;
            a.innerText = "直达下载";
            downloadBtn?.parentNode?.appendChild(a);
            // downloadBtn.remove();
        }
     
        // 这是匹配旧版本的下载链接
        let downloadBtn = document.getElementsByClassName("download_link")[0];
        if (!downloadBtn) {
     
            // 新版本的下载链接
            // 获取 .down-tip > a:nth-child(2) 的href
            downloadBtn = document.querySelector(".down-tip > a:nth-child(2)");
            if (!downloadBtn) {
                return
            }
        }
     
        if (downloadBtn) {
            createDownload(downloadBtn);
        }
     
        // 新版本下载还有一个跳转页面需要处理
        let downloadLink = document.getElementsByClassName("ss-button")[0];
        if (downloadLink) {
            location.href = downloadLink.href;
        }
    })();