Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save cuylerstuwe/0bbcafa91120832f1855a713598f5786 to your computer and use it in GitHub Desktop.

Select an option

Save cuylerstuwe/0bbcafa91120832f1855a713598f5786 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Panda Crazy Timer Discrepancy In Title
// @namespace salembeats
// @version 2.5
// @description Timer descrepancy test to demonstrate background tab timer throttling. Runs on TurkerHub and displays results in the tab's title bar.
// @author Cuyler Stuwe (salembeats)
// @include http*://worker.mturk.com/?filters[search_term]=pandacrazy=on*
// @include http*://worker.mturk.com/requesters/PandaCrazy/projects*
// @include http*://worker.mturk.com/?PandaCrazy*
// @include http*://worker.mturk.com/?end_signin=1&filters%5Bsearch_term%5D=pandacrazy%3Don*
// @icon https://i.imgur.com/snRSm80.gif
// @grant none
// ==/UserScript==
var INTERVAL_TIME = 700;
var lastTimestamp;
var mostRecentTimestamp;
var lastGap;
setInterval(() => {
lastTimestamp = mostRecentTimestamp;
mostRecentTimestamp = performance.now();
if(lastTimestamp !== undefined && mostRecentTimestamp !== undefined) {
lastGap = mostRecentTimestamp - lastTimestamp;
let deviationAmount = Math.abs(INTERVAL_TIME - lastGap);
let deviationPercentage = (deviationAmount / INTERVAL_TIME) * 100;
document.title = `PC (${deviationPercentage.toLocaleString("EN", {maximumFractionDigits: 0})}% lag) [${INTERVAL_TIME}ms]`;
}
}, INTERVAL_TIME);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment