京东自动秒杀抢券php,【原创源码】【JavaScript】「京东超级百亿补贴」定时抢券脚本...

这段代码是一个JavaScript用户脚本,用于在指定时间自动滚动页面加载商品,并在找到特定关键词的商品时尝试进行抢购。脚本会在指定的开始时间前5秒开始准备,然后在抢购时间点尝试刷新页面并滚动加载商品列表。当找到包含关键词的商品并且显示为限量但未开始抢购时,脚本会尝试点击抢购按钮。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[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...

})();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值