Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG-nightly.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Remove hosted-site functionality
- Use new pubsub source
- Added randomized delay to Autoclaim channel points feature

### 3.1.8.1000

Expand Down
9 changes: 9 additions & 0 deletions src/site/twitch.tv/modules/autoclaim/AutoclaimModule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ const lock = ref(false);
const doClaim = debounceFn(async (inst: HookedInstance<Twitch.ChatChannelPointsClaimComponent>) => {
if (lock.value || typeof inst.component.onClick !== "function") return;

// Generate a random delay from 1000 to 7000 ms
const delay = 1000 + Math.floor(Math.random() * 6000);

log.debug(`Delaying claim by ${delay}ms`);
await new Promise((resolve) => setTimeout(resolve, delay));

// Check if the component or state has gone away during the wait time
if (lock.value || typeof inst.component.onClick !== "function") return;

inst.component.onClick();

// Prevent further clicks while the button is reverting to its original state
Expand Down