Skip to content

Instantly share code, notes, and snippets.

@malash
Last active October 16, 2025 19:54
Show Gist options
  • Save malash/3a59c6a5161d0461c437986ed719032a to your computer and use it in GitHub Desktop.
Save malash/3a59c6a5161d0461c437986ed719032a to your computer and use it in GitHub Desktop.
A user script to keep Slack status active
// ==UserScript==
// @name Slack Keep Active
// @version 1.0.0
// @description Slack Keep Active
// @author Malash
// @match *://app.slack.com/*
// ==/UserScript==
function isWorkingTime(date = new Date()) {
const day = date.getDay(); // 0 = Sunday, 1 = Monday, ..., 6 = Saturday
const hours = date.getHours();
const minutes = date.getMinutes();
if (day < 1 || day > 5) {
return false;
}
const totalMinutes = hours * 60 + minutes;
const startMinutes = 9 * 60 + 30; // 09:30
const endMinutes = 23 * 60; // 23:00
return totalMinutes >= startMinutes && totalMinutes <= endMinutes;
}
const tickle = () => {
if (!isWorkingTime()) {
return;
}
window.dispatchEvent(new Event('blur'));
setTimeout(() => {
window.dispatchEvent(new Event('focus'));
}, 1000);
}
const MIN_INTERVAL = 19 * 1000;
const MAX_INTERVAL = 5 * 60 * 1000;
const schedule = () => {
const timeout = Math.random() * (MAX_INTERVAL - MIN_INTERVAL) + MIN_INTERVAL;
setTimeout(() => {
tickle();
schedule();
}, timeout);
}
schedule();
@brendandebeasi
Copy link

Is there any way to check if this is working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment