Skip to content

Instantly share code, notes, and snippets.

@zhanglongqi
Last active December 30, 2022 01:51
Show Gist options
  • Save zhanglongqi/764f8184a6e228e9796fdfd799a7ec7f to your computer and use it in GitHub Desktop.
Save zhanglongqi/764f8184a6e228e9796fdfd799a7ec7f to your computer and use it in GitHub Desktop.
auto-starter-for-motionmark
AAA-auto-starter-for-motionmark
// ==UserScript==
// @name auto starter for motionmark
// @description auto starter for motionmark
// @namespace https://zhanglongqi.github.io
// @version 0.1.3
// @author Zhang LongQi
// @match https://browserbench.org/MotionMark1.2/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @updateURL https://gist.github.com/zhanglongqi/764f8184a6e228e9796fdfd799a7ec7f/raw/auto-starter-for-motionmark.meta.js
// @downloadURL https://gist.github.com/zhanglongqi/764f8184a6e228e9796fdfd799a7ec7f/raw/auto-starter-for-motionmark.user.js
// ==/UserScript==
// ==UserScript==
// @name auto starter for motionmark
// @description auto starter for motionmark
// @namespace https://zhanglongqi.github.io
// @version 0.1.3
// @author Zhang LongQi
// @match https://browserbench.org/MotionMark1.2/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @updateURL https://gist.github.com/zhanglongqi/764f8184a6e228e9796fdfd799a7ec7f/raw/auto-starter-for-motionmark.meta.js
// @downloadURL https://gist.github.com/zhanglongqi/764f8184a6e228e9796fdfd799a7ec7f/raw/auto-starter-for-motionmark.user.js
// ==/UserScript==
(async function () {
"use strict";
console.debug("auto starter for motionmark ");
function start_benchmark_controller() {
setTimeout(() => {
if (
typeof benchmarkController !== "undefined" &&
typeof benchmarkController.startBenchmark === "function"
) {
console.debug("try to start benckmark");
try {
benchmarkController.startBenchmark();
} catch (err) {
sessionStorage.removeItem("timer_started");
console.error(err);
window.location.reload(true);
}
} else {
console.warn("benchmark controller is not ready");
}
}, 5000);
}
let timer_started = JSON.parse(sessionStorage.timer_started || false);
// timer_started = new Date(timer_started);
if (timer_started) {
console.log("timer was started");
} else {
start_benchmark_controller();
let timer_id = setInterval(() => {
start_benchmark_controller();
}, 1000 * 60 * 10);
console.info(`timer is on ${timer_id}`);
sessionStorage.setItem("timer_started", true);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment