Skip to content

Instantly share code, notes, and snippets.

@adriaandotcom
Created June 8, 2022 11:02
Show Gist options
  • Save adriaandotcom/0cbf9de50158db007ae4766f03a96965 to your computer and use it in GitHub Desktop.
Save adriaandotcom/0cbf9de50158db007ae4766f03a96965 to your computer and use it in GitHub Desktop.
Fix Twitter's schedule tweet feature
javascript: (function () {
const currentHour = new Date().getHours();
const scheduleHour =
currentHour < 10 ? 10 : currentHour < 14 ? 14 : currentHour < 17 ? 17 : 10;
const addDays = currentHour < 17 ? 0 : 1;
const date = new Date(Date.now() + addDays * 24 * 60 * 60 * 1000);
const [month, day, year, hour, minute] = document.querySelectorAll(
'[role="dialog"] select'
);
month.value = date.getMonth() + 1;
month.dispatchEvent(new Event("change", { bubbles: true }));
day.value = date.getDate();
day.dispatchEvent(new Event("change", { bubbles: true }));
year.value = date.getFullYear();
year.dispatchEvent(new Event("change", { bubbles: true }));
hour.value = scheduleHour;
hour.dispatchEvent(new Event("change", { bubbles: true }));
minute.value = Math.round(Math.random() * 10);
minute.dispatchEvent(new Event("change", { bubbles: true }));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment