Build a Chrome Extension to Auto‑Click Taobao Red‑Envelope Buttons
This guide walks through building a Chrome extension that automatically clicks Taobao’s red‑envelope buttons, covering folder setup, manifest configuration, XPath button detection, script insertion, loading the extension in developer mode, and testing while noting anti‑cheat limitations.
Motivation
After hearing a friend receive a large red‑envelope reward during the Double‑Eleven promotion, the author decided to experiment with a script that could automatically click the red‑envelope button on Taobao’s promotional pages.
Creating the Chrome Extension
First, a local directory named click is created. Inside it a manifest.json file defines the extension:
name : the extension name
manifest_version : fixed value 2
content_scripts : the target website patterns
js : scripts to load (e.g., jquery-2.1.4.min.js and main.js)
An illustration of the manifest file is shown below:
Writing the Content Script
The script first locates the “grab red envelope” button. Because the button lacks convenient identifiers, an XPath expression is used. The XPath for the first button is shown in the following image:
The XPath for the “grab again” button is similar:
The JavaScript code that performs the click is placed in main.js. The complete code is displayed in the next screenshot:
The script works, but Taobao’s anti‑cheat system quickly blocks the account after a few hundred attempts. The author suggests randomising the click interval to reduce detection, though the exact code is omitted.
Loading and Testing the Extension
Chrome’s developer mode is enabled, and the click folder is loaded as an unpacked extension. The loading screen is shown below:
After refreshing the red‑envelope page, the automatic clicking takes effect. The author warns against excessive use, noting that their account was eventually banned.
Source: segmentfault
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
ITPUB
Official ITPUB account sharing technical insights, community news, and exciting events.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
