Managing multiple MTurk accounts can be tedious. What if you could paste multiple HIT set IDs once and let a userscript automatically accept HITs for all connected accounts?
Here’s how I built a centralized MTurk HIT catcher using PHP, a JSON endpoint, and a userscript.
Features
-
Central PHP page to save and manage HIT set IDs.
-
Toggle catching HITs on/off.
-
JSON endpoint for userscripts to fetch IDs.
-
Userscript auto-accepts HITs for multiple accounts.
-
Server rendering using Ngrok for remote access.
PHP Controller (hitaccept.php)
This page allows you to save HIT set IDs, see the current status, and serve IDs as JSON.
Back";
exit;
}
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$data = $_POST["hit_ids"] ?? "";
$ids = array_filter(array_map("trim", explode("\n", $data)));
file_put_contents($file, json_encode($ids));
echo "Saved! Back";
exit;
}
if (isset($_GET["json"])) {
header("Content-Type: application/json");
$status = file_exists($statusFile) ? trim(file_get_contents($statusFile)) : "on";
$ids = file_exists($file) ? file_get_contents($file) : "[]";
echo json_encode([
"status" => $status,
"ids" => json_decode($ids, true)
]);
exit;
}
$current = file_exists($file) ? file_get_contents($file) : "[]";
$status = file_exists($statusFile) ? trim(file_get_contents($statusFile)) : "on";
?>
MTurk HIT Controller
📋 Paste HIT Set IDs (one per line)
Current HIT IDs
Status:
▶️ Start Catching |
⏹ Stop Catching
JSON endpoint: hitaccept.php?json
What it does:
Userscript for Auto-Accepting HITs
Install in Tampermonkey or Greasemonkey:
// ==UserScript==
// @name MTurk Central HIT Catcher
// @namespace yourdomain.com
// @version 1.0
// @description Accept HITs automatically from set_ids provided by central server
// @match https://worker.mturk.com/*
// @grant GM_xmlhttpRequest
// ==/UserScript==
(function() {
'use strict';
const SERVER_URL = "https://your-ngrok-url.ngrok-free.app/hitaccept.php?json";
const FETCH_INTERVAL = 10000; // 10s
function fetchSetIdsAndCatch() {
GM_xmlhttpRequest({
method: "GET",
url: SERVER_URL,
onload: function(response) {
try {
let data = JSON.parse(response.responseText);
if (data.status === "off") {
console.log("⏹ Catcher stopped by server.");
return;
}
let ids = data.ids || [];
ids.forEach(id => {
let acceptUrl = `https://worker.mturk.com/projects/${id}/tasks/accept_random?format=json`;
GM_xmlhttpRequest({
method: "GET",
url: acceptUrl,
onload: function(res) {
if (res.status === 200 && res.responseText.includes("task_id")) {
console.log("✅ Accepted HIT:", id);
} else {
console.log("❌ No HITs available for:", id);
}
}
});
});
} catch (e) {
console.error("Error parsing JSON:", e);
}
}
});
}
setInterval(fetchSetIdsAndCatch, FETCH_INTERVAL);
console.log("🚀 MTurk Central HIT Catcher started, polling every", FETCH_INTERVAL/1000, "seconds");
})();
Running the Project
- Start your PHP server locally:
php -S localhost:8000
- Expose it to the internet via Ngrok:
ngrok http 8000
- Replace SERVER_URL in your userscript with your Ngrok URL:
https://your-ngrok-url.ngrok-free.app/hitaccept.php?json
-
Open the Tampermonkey dashboard and activate the script.
-
Go to hitaccept.php, paste your HIT set IDs, and click Start Catching.
-
Check your browser console for logs:
-
HIT accepted
-
No HITs available
Summary
With this setup, you can:
-
Centralize multiple HIT IDs.
-
Control the catching process via a web interface.
-
Automatically accept HITs across multiple accounts.
It’s perfect for heavy MTurk users or small teams who need automation without manual repetition.