吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 424|回复: 21
收起左侧

[经验求助] 有会写油猴脚本的大佬吗,求助

[复制链接]
如你是我 发表于 2024-3-5 20:27
50吾爱币
123网盘最近用idm下载会限速,网上说把下载链接里面的
https://175-153-168-144.pd1.123pan.cn:30443/download-cdn.123pan.cn/123-387/33e26a92/1625770-0/33e26a921d36498abe9c25a4df999583/c-m18?pan123_down_pre=1&v=5


pan123_down_pre=1这一串删掉就好了,
实测是可行的,但是每次手动删好麻烦
有没有大佬会写油猴脚本,123云盘分享的文件点下载调用IDM下载的时候自动去掉这一串?
或者有别的方法自动去掉也行

最佳答案

查看完整内容

我测试了几次,我这边没有用任何脚本点击下载获得的链接都没有“pan123_down_pre=1”这个,所以没办法测试,只能盲写。我写了个你再试试。直接点下载会过滤这个代码。 [mw_shl_code=javascript,true]// ==UserScript== // @name 移除123盘下载链接多余代码 // @namespace http://tampermonkey.net/ // @version 1.0 // @description Remove the 'pan123_down_pre=1' parameter from the download URL // ...

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

sexcat 发表于 2024-3-5 20:27
我测试了几次,我这边没有用任何脚本点击下载获得的链接都没有“pan123_down_pre=1”这个,所以没办法测试,只能盲写。我写了个你再试试。直接点下载会过滤这个代码。

[JavaScript] 纯文本查看 复制代码
// ==UserScript==
// @name         移除123盘下载链接多余代码
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Remove the 'pan123_down_pre=1' parameter from the download URL
// @author       icescat
// @match        *://*.123pan.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 添加事件监听器,监听所有点击事件
    document.addEventListener('click', function(e) {
        // 尝试获取点击目标的最近的a标签元素,且该a标签的href属性包含特定的下载链接
        let target = e.target.closest('a[href*="download-cdn.123pan.cn"]');
        // 如果找到了符合条件的a标签
        if (target) {
            // 获取该a标签的href属性,即下载链接
            let originalUrl = target.getAttribute('href');
            // 使用URL对象来解析和修改链接
            let url = new URL(originalUrl);
            // 检查链接中是否包含pan123_down_pre=1参数
            if (url.searchParams.has('pan123_down_pre=1')) {
                // 如果包含,则移除该参数
                url.searchParams.delete('pan123_down_pre=1');
                // 更新a标签的href属性为移除参数后的新链接
                target.setAttribute('href', url.toString());
                // 阻止原始的点击事件,以避免跳转到未修改的链接
                e.preventDefault();
                // 手动跳转到新的下载链接
                window.location.href = url.toString();
            }
        }
    }, true);
})();

sexcat 发表于 2024-3-5 21:37
根据你说的描述,我写了一段,你可以试一下,有什么问题再反馈给我

[JavaScript] 纯文本查看 复制代码
// ==UserScript==
// @name         123云盘分享链接修改器
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  自动去除123云盘分享链接中的特定参数
// @author       You
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 检测当前URL是否为123云盘的分享链接,并且含有特定的参数
    if (window.location.href.includes('123pan.cn') && window.location.search.includes('pan123_down_pre=1')) {
        // 创建一个新的URL,去除特定的参数
        let newUrl = window.location.href.replace(/&?pan123_down_pre=1&?/, '');
        // 重定向到新的URL
        window.location.replace(newUrl);
    }
})();
sexcat 发表于 2024-3-5 21:38
[JavaScript] 纯文本查看 复制代码
// ==UserScript==
// @name         123云盘分享链接修改器
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  自动去除123云盘分享链接中的特定参数
// @author       You
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 检测当前URL是否为123云盘的分享链接,并且含有特定的参数
    if (window.location.href.includes('123pan.cn') && window.location.search.includes('pan123_down_pre=1')) {
        // 创建一个新的URL,去除特定的参数
        let newUrl = window.location.href.replace(/&?pan123_down_pre=1&?/, '');
        // 重定向到新的URL
        window.location.replace(newUrl);
    }
})();
 楼主| 如你是我 发表于 2024-3-6 11:32
sexcat 发表于 2024-3-6 17:11
如你是我 发表于 2024-3-6 11:32
不行,别人分享的连接点下载时调用IDM 获取的下载地址https://223-113-14-20.pd1.123pan.cn:30443/downlo ...

你首先看油猴脚本在你所在的页面启用没有,然后你点击这个链接看跳过去的窗口地址栏,我刚才试着点了你这个链接,那段代码已经没有了
 楼主| 如你是我 发表于 2024-3-6 18:46
sexcat 发表于 2024-3-6 17:11
你首先看油猴脚本在你所在的页面启用没有,然后你点击这个链接看跳过去的窗口地址栏,我刚才试着点了你这 ...

分享链接界面是启用的,但是点下载按钮后会调用IDM下载,IDM获取的下载链接还是有这段代码


我刚直接在浏览器复制那段链接,也是跳转到IDM下载 还是有那串代码
sexcat 发表于 2024-3-6 21:48
换了个思路,我在123盘的链接后面新加一个去掉那个代码的新链接按钮,你再试试,按钮用红色粗体写了IDM下载几个字

[JavaScript] 纯文本查看 复制代码
// ==UserScript==
// [url=home.php?mod=space&uid=170990]@name[/url]         123盘IDM下载按钮添加器
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  为123盘分享链接旁边添加一个IDM下载按钮
// @author       icescat
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 函数:为符合条件的链接添加IDM下载按钮
    function addIdmDownloadButton() {
        // 查找页面上所有的链接元素
        const links = document.querySelectorAll('a');

        // 遍历所有链接
        links.forEach(link => {
            // 检查链接是否包含123盘分享链接特征
            if (link.href.includes('123pan.cn') && link.href.includes('pan123_down_pre=1')) {
                // 创建一个新的下载按钮
                const idmButton = document.createElement('a');
                idmButton.textContent = 'IDM下载'; // 设置按钮文字
                idmButton.style.marginLeft = '10px'; // 添加一些样式,以便按钮不会紧挨着链接

                // 设置按钮样式为红色粗体
                idmButton.style.color = 'red';
                idmButton.style.fontWeight = 'bold';

                // 构造新的链接地址,移除"pan123_down_pre=1"参数
                const newHref = link.href.replace(/&?pan123_down_pre=1&?/, '');
                idmButton.href = newHref;
                idmButton.setAttribute('download', ''); // 提示浏览器下载而非导航
                idmButton.style.cursor = 'pointer';

                // 将新按钮添加到链接旁边
                link.parentNode.insertBefore(idmButton, link.nextSibling);
            }
        });
    }

    // 页面载入完成后,调用函数添加下载按钮
    window.addEventListener('load', addIdmDownloadButton);
})();
 楼主| 如你是我 发表于 2024-3-7 08:40
sexcat 发表于 2024-3-6 21:48
换了个思路,我在123盘的链接后面新加一个去掉那个代码的新链接按钮,你再试试,按钮用红色粗体写了IDM下载 ...

脚本启用了,但是网页上没有IDM下载的字样
sexcat 发表于 2024-3-7 09:12
哦你是在这个页面啊,你早说啊
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-5-21 19:25

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表