Mturk Contribute to "Seen" API

When browsing mTurk, notify that seen HITs have been seen.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Mturk Contribute to "Seen" API
// @namespace    salembeats
// @version      1.03
// @description  When browsing mTurk, notify that seen HITs have been seen.
// @author       Cuyler Stuwe (salembeats)
// @include      https://worker.mturk.com/
// @include      https://worker.mturk.com/projects
// @include      https://worker.mturk.com/projects/
// @include      https://worker.mturk.com/projects?page_size*
// @include      https://worker.mturk.com/?end_signin=1*
// @include      https://worker.mturk.com/?page_number*
// @include      https://worker.mturk.com/projects/?page_number=*
// @include      https://worker.mturk.com/?page_size=*&page_number=*
// @require      https://cdnjs.cloudflare.com/ajax/libs/pako/1.0.8/pako.min.js
// @grant        GM_xmlhttpRequest
// @connect      cuylerstuwe.com
// @noframes
// ==/UserScript==

const USE_LOGS = false;
const log = USE_LOGS ? (text) => console.log(text) : (text) => {};

async function sendSeenLog(jsonStr) {
    const data = encodeURIComponent(jsonStr);
    const compressed = pako.deflate(data);

    fetch("https://www.cuylerstuwe.com:12121/seen", {
        method: "POST",
        body: new Blob([ compressed ], { type: 'application/octet-stream'})
    });
}

async function main() {
    const hitsTable = document.querySelector("[data-react-class*='hitSetTable']");
    if(!hitsTable) {return;}
    const hits = JSON.parse(hitsTable.dataset.reactProps).bodyData;
    const payload = JSON.stringify(hits);
    sendSeenLog(payload);
    log("Sent this payload of seen HITs:");
    log(payload);
}

main();