This code defines a **UserScript**, a type of script often...
This code defines a UserScript, a type of script often used with userscript managers like Tampermonkey or Greasemonkey, designed to modify or enhance the functionality of a specific website—in this case, https://www.lootlink.me/. Here's what the script does in detail:
General Overview:
The script automates multiple actions on the lootlink.me website:
- Adds labels for user feedback.
- Automates daily actions (claiming daily rewards and opening loot crates).
- Adds buttons for multi-loot actions (e.g., "5 consecutive draws", "10 consecutive draws", "all draws").
- Handles retrying actions in case certain elements are not yet loaded.
- Provides notifications or updates on the progress of automated tasks.
Detailed Functionality:
- Metadata Block:
- Specifies details about the script like its name, version, author, description, what sites it applies to (
@include
), and URLs for updates/downloads. - For example:
- Name: "Auto Loot"
- URL applies to:
https://www.lootlink.me/*
- Specifies details about the script like its name, version, author, description, what sites it applies to (
- Immediately Invoked Function Expression (IIFE):
- The script is encapsulated in an IIFE (
(function () { ... })()
) to avoid polluting the global namespace. - Calls three main functions when executed:
showLabel()
dailyClaim()
add10xBtn()
- The script is encapsulated in an IIFE (
-
Function Descriptions:
a)
showLabel()
- Adds custom feedback labels/buttons (e.g., "反馈" and "By Chr_") next to the user's profile menu.
- These labels:
- Navigate users to feedback and developer-related web pages when clicked.
b)
dailyClaim()
- Automates daily actions like claiming daily rewards and opening crates.
- Key Actions:
- Check if daily reward crates are available:
- Looks for clickable elements like coin icons or crate images.
- Triggers their click events.
- Claim the rewards:
- Finds and clicks the "claim" button inside the crate modal.
- Close the modal:
- Waits for confirmation that the crate reward is opened or received, then closes the modal.
- Handles retries:
- Utilizes a retry mechanism to handle cases where the elements might not have loaded instantly.
- Check if daily reward crates are available:
c) add10xBtn()
- Dynamically adds custom buttons for multi-loot actions next to existing loot buttons.
- Buttons include:
- "五连" (5 consecutive draws)
- "十连" (10 consecutive draws)
- "梭哈" (100 consecutive draws)
- Each button is configured to trigger the
loot10x
function upon clicking.
d) loot10x(e)
- Automates a multi-loot process (triggered by the buttons added by
add10xBtn()
). - Key Operations:
- Determines the desired number of draws based on the clicked button's ID.
- Initiates the multi-loot process by clicking loot buttons.
- Keeps track of loot progress and displays updates (e.g., "抽完啦" which translates to "Done with draws").
- Uses a retry mechanism to wait for each loot action to complete before proceeding.
- Handles situations where the required elements are missing or actions timeout.
- Retry Mechanisms:
- Several functions (
retry(foo, t)
) help handle asynchronous or lag-prone scenarios:- Retries a task (
foo
) up to a specified maximum number of times (MAX
). - Waits for a specified timeout (
t
) between attempts, ensuring the DOM elements have time to load.
- Retries a task (
- Several functions (
Summary:
This script automates daily interactions and multi-loot actions on the lootlink.me website. It enhances the UX by offering streamlined operations (e.g., "daily claim", "multi-loot"), adding custom feedback links, and handling user interaction in an optimized manner. The script relies heavily on DOM manipulation, event listeners, and retry mechanisms to manage asynchronous processes effectively.