Skip to content

Instantly share code, notes, and snippets.

@brouwerfp
Last active July 16, 2023 15:40
Show Gist options
  • Select an option

  • Save brouwerfp/7a10fdf3c6dbce2660803c4a1ed792ca to your computer and use it in GitHub Desktop.

Select an option

Save brouwerfp/7a10fdf3c6dbce2660803c4a1ed792ca to your computer and use it in GitHub Desktop.
Reloads the top page of Misskey in 30 min cycle to keep the session of your Misskey service, Usable in Tampermonkey
// ==UserScript==
// @name Misskey Session Keeper
// @namespace https://brouwerfp.org/
// @version 0.3
// @description try to take over the world!
// @author Brouwerfp
// @match https://misskey.brouwerfp.org/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const interval = 8_000, blur = 4_000, limit = 200_000 / interval;
const Y = (f) => ((x) => x(x))((x) => setTimeout(() => f(x(x)), sleeping_for));
const loop = () => {
let date = new Date();
if(count > limit && date.getMinutes() % 30 === 0){
location.reload();
}
console.log("Misskey Session Keeper: ", date, "count: ", count, "sleeped: ", date.getTime() - sleeped);
count++;
sleeping_for = interval + (Math.random()*blur*2|0) - blur;
sleeped = date.getTime();
};
let count = 0, sleeping_for = interval, sleeped = (new Date()).getTime();
Y(loop);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment