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

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 18410|回复: 49
收起左侧

[Java 原创] 【原创源码】【JavaScript】「京东超级百亿补贴」定时抢券脚本

  [复制链接]
Coolman 发表于 2019-11-5 21:10
本帖最后由 Coolman 于 2019-11-9 14:43 编辑

京东超级百亿补贴活动,定时抢券脚本

作为一个 BED(back-end dog,此处应该有狗头 🐶),论坛首次发帖献丑,欢迎各位大佬指摘。

此脚本经本人多次迭代,理论上是可行的。若由于其他各种因素不能达到期望效果,欢迎各种形式的改进建议。

使用方法

  • 打开浏览器控制台,复制粘贴以下代码并运行。
  • 导入浏览器扩展(油猴脚本),直接运行。

根据自己的需要修改关键词抢购时间,注意只有 15 次机会,不要抢没用的券。

脚本代码

get-jd-coupon.js

更新(2019-11-06 01:22)

根据 @gray小灰 大佬的回复(感谢 🙏),修复了 getServerTime 函数的问题。

更新(2019-11-06 18:22)

感谢 @dongboy 大佬的解决方案,我们可以借助浏览器扩展(油猴脚本)来实现。

参考方案28#

更新(2019-11-09 00:26)

感谢大家的反馈 ❤️,请使用最新源码。

最新源码地址https://gist.github.com/55a14dab8766eedda13268e931a4d09e
最新源码地址(国内可正常访问)https://gitee.com/Coolman/55a14dab8766eedda13268e931a4d09e.git

免费评分

参与人数 7吾爱币 +7 热心值 +7 收起 理由
saner + 1 + 1 非常棒,如果有京东炸年兽脚本就更好了fυ製@30JufBu33b@这段话后咑開最新.
13925622740 + 1 用心讨论,共获提升!
凉爽的大西瓜 + 1 + 1 我很赞同!
GGbond + 1 大佬试试这个地址:https://api.m.jd.com/client.action?functionId=newBab.
linvvavn + 1 + 1 先支持下,晚上试试
showwh + 1 + 1 谢谢@Thanks!
苏紫方璇 + 3 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!

查看全部评分

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

gray小灰 发表于 2019-11-5 23:31
第25行报错,改了一下就可以运行了
[JavaScript] 纯文本查看 复制代码
(() => {
    // https://birth.m.jd.com/babelDiy/Zeus/3DMauchBtuvSfu5XwMW1hgdZeLxr/index.html
    const keywords = ['鸡蛋', '爱媛38号果冻橙柑橘', '京觅 精品琯溪蜜柚',]; // 想要的关键词
    const moument = '2019-11-06 00:00'; // 抢购时间

    const ms = +new Date(moument); // 抢购时间毫秒值
    const pre = +new Date(ms - 1000 * 5); // 提前 5 秒钟准备
    const end = +new Date(ms + 1000 * 60 * 3); // 三分钟之后结束

    let reloaded = false;

    const part1 = document.querySelector('#NavPart1'); // 列表容器

    // 滚动百亿补贴列表,使其全部加载出来
    const scroll = () => {
        for (let i = 0; i < 18; i++) {
            setTimeout(() => {
                part1.scrollIntoView(false);
            }, 100 * i);
        }
    };

    // 获取服务器时间戳
    const getServerTime = () => async function test(){
        const header = await fetch('.', {
                method: 'head',
            }).then((response) => {
                return response.headers;
            });

        return +new Date(header.get('Date'));
    };

    const intervalId = setInterval(() => {
        console.log(`it is running...`);
        const now = getServerTime();
        // 结束了
        if (now >= end) {
            console.info(`it's time to end.`);
            clearInterval(intervalId);
            return;
        }
        // 准备时间
        if (now >= pre) {
            console.log(`it's time to go...`);
            if (now >= ms) {
                // 到点页面不会自动刷新,需要手动加载一下
                if (!reloaded) {
                    location.reload();
                    reloaded = true;
                    setTimeout(scroll, 600);
                }
                const items = part1.querySelectorAll('div.BillionSubsidy-content-item-coupon');
                for (let item of items) {
                    const name = item.querySelector('div.BillionSubsidy-content-item-coupon-name');
                    for (let key of keywords) {
                        if (name.innerText.includes(key)) {
                            console.log(`key: [${ key }], matched: [${ name.innerText }]`);
                            const right = item.querySelector('div.BillionSubsidy-content-item-coupon-right-container');
                            const down = item.querySelector('div.BillionSubsidy-content-item-coupon-right-down');
                            if (right.innerText.includes('限量') && !right.innerText.includes('开抢')) {
                                console.log(`wanna [${ key }], matched ${ name.innerText }`);
                                if (down) {
                                    console.info(`--- ${ name.innerText } ---`);
                                    // down.click();
                                    // down.remove();
                                    console.info(`*** u get it ***`);
                                }
                            }
                        }
                    }
                }
            }
        }
    }, 800);
})();
 楼主| Coolman 发表于 2019-11-8 14:35
GGbond 发表于 2019-11-8 06:35
评分那个搞错了,是这个:https://prodev.m.jd.com/mall/active/2F3KrzC3cVRqVZNxoDoVgz5StZZ8/index.html

file-get-free-coupons-js 可以试下~

GGbond 发表于 2019-11-8 06:35
评分那个搞错了,是这个:https://prodev.m.jd.com/mall/active/2F3KrzC3cVRqVZNxoDoVgz5StZZ8/index.html

免费评分

参与人数 1热心值 +1 收起 理由
Coolman + 1 热心回复!

查看全部评分

dongboy 发表于 2019-11-6 17:41
本帖最后由 dongboy 于 2019-11-6 17:44 编辑

油猴脚本
[JavaScript] 纯文本查看 复制代码
// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @AuThor       You
// @match        https://birth.m.jd.com/babelDiy/Zeus/3DMauchBtuvSfu5XwMW1hgdZeLxr/index.html
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    // https://birth.m.jd.com/babelDiy/Zeus/3DMauchBtuvSfu5XwMW1hgdZeLxr/index.html
    const keywords = ['鸡蛋', '媛38号果冻橙柑橘','京觅 精品琯溪蜜柚',]; // 想要的关键词
    const moument = '2019-11-06 10:00'; // 抢购时间

    const ms = +new Date(moument); // 抢购时间毫秒值
    const pre = +new Date(ms - 1000 * 5); // 提前 5 秒钟准备
    const end = +new Date(ms + 1000 * 60 * 3); // 三分钟之后结束

    let reloaded = false;

    // 滚动百亿补贴列表,使其全部加载出来
    const scroll = () => {
        const part1 = document.querySelector('#NavPart1'); // 列表容器
        for (let i = 0; i < 18; i++) {
            setTimeout(() => {
                part1.scrollIntoView(false);
            }, 100 * i);
        }
    };

    // 获取服务器时间戳
    const getServerTime = async () => {
        return +new Date((await fetch(`?${ +new Date() }`, {
            method: 'head',
        }).then((res) => res.headers)).get("Date"));
    };

    const intervalId = setInterval(() => {
        console.log(`it is running...`);
        getServerTime().then(now => {
            console.log(`server time: ${ now }`);
            // 结束了
            if (now >= end) {
                console.info(`it's time to end.`);
                clearInterval(intervalId);
                return;
            }
            // 准备时间
            if (now >= pre) {
                console.log(`it's time to go...`);
                if (now >= ms) {
                    // 到点页面不会自动刷新,需要手动加载一下
                    if (now - ms < 810) {
                        // FIXME
                        location.reload();
                    }
                    if (!reloaded) {
                        // FIXME
                        //location.reload();
                        reloaded = true;
                        setTimeout(scroll, 600);
                    }
                    const part1 = document.querySelector('#NavPart1'); // 列表容器
                    const items = part1.querySelectorAll('div.BillionSubsidy-content-item-coupon');
                    for (let item of items) {
                        const name = item.querySelector('div.BillionSubsidy-content-item-coupon-name');
                        for (let key of keywords) {
                            if (name.innerText.includes(key)) {
                                console.log(`key: [${ key }], matched: [${ name.innerText }]`);
                                const right = item.querySelector('div.BillionSubsidy-content-item-coupon-right-container');
                                const down = item.querySelector('div.BillionSubsidy-content-item-coupon-right-down');
                                if (right.innerText.includes('限量') && !right.innerText.includes('开抢')) {
                                    console.log(`wanna [${ key }], matched ${ name.innerText }`);
                                    if (down) {
                                        console.info(`--- ${ name.innerText } ---`);
                                        down.click();
                                        //down.remove();
                                        console.info(`*** u get it ***`);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        });
    }, 800);
    // Your code here...
})();

免费评分

参与人数 1吾爱币 +1 热心值 +1 收起 理由
Coolman + 1 + 1 谢谢@Thanks!

查看全部评分

王美君 发表于 2019-11-5 21:23
占个沙发,谢谢分享
beneny 发表于 2019-11-5 21:26
这个就厉害了  先占位
ahxhwcp 发表于 2019-11-5 21:31
厉害了、、、
zjk414 发表于 2019-11-5 21:33
占个沙发,谢谢分享
亿联网络 发表于 2019-11-5 21:39
大佬,给大佬递头
o0dc0o 发表于 2019-11-5 21:39
感谢楼主分享,支持一下!
putao2014 发表于 2019-11-5 21:50
小米的券能抢不?
liuhiulin 发表于 2019-11-5 21:52

这个就厉害了  先占位
曽师少年 发表于 2019-11-5 21:53
最新地址网络错误怎么回事啊??
您需要登录后才可以回帖 登录 | 注册[Register]

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

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

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

GMT+8, 2024-5-29 14:36

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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