Skip to content

Instantly share code, notes, and snippets.

@Inve1951
Last active January 5, 2025 07:30
Show Gist options
  • Save Inve1951/00c520b04cf44f72804cf33b58019318 to your computer and use it in GitHub Desktop.
Save Inve1951/00c520b04cf44f72804cf33b58019318 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Miruru
// @version 0.1.5
// @description UX improvements
// @author square
// @match https://www.miruro.tv/watch*
// @match https://www.miruro.to/watch*
// @match https://www.miruro.online/watch*
// @icon https://www.miruro.tv/icons/favicon-32x32.png
// @grant none
// @downloadURL https://gist.github.com/Inve1951/00c520b04cf44f72804cf33b58019318/raw/Miruru.user.js
// ==/UserScript==
(function() {
'use strict';
document.addEventListener("keypress", ev => {
if (document.activeElement?.matches("input[type=text], input[type=password], input[type=search], textarea")) return;
if (ev.code === "KeyS") {
document.querySelector(".skip-button, .next-episode-button")?.click();
}
else if (ev.code === "KeyN") {
document.querySelector(".next-episode-button")?.click();
}
else return;
ev.preventDefault();
ev.stopImmediatePropagation();
}, true);
let patched = 0;
const video_patch = 1 << patched++;
const title_patch = 1 << patched++;
const all_patches = (1 << patched) - 1;
patched = 0;
(function frame() {
if (!(patched & video_patch)) {
const video = document.querySelector("video");
if (video) {
video.focus();
patched |= video_patch;
}
}
if (!(patched & title_patch)) {
const title = document.querySelector("title");
if (title) {
monitor(title, ([{ target: title }]) => {
const m = /^Watch (.+) · Miruro$/.exec(title.textContent);
if (m) {
title.textContent = m[1];
return;
}
});
patched |= title_patch;
}
}
if (patched === all_patches) return;
requestAnimationFrame(frame);
})();
function monitor(node, cb) {
const obs = new MutationObserver(cb);
obs.observe(node, { childList: true });
cb([{ target: node, type: "childList", addedNodes: [], removedNodes: [] }], obs);
}
})();
0.1.5 re-patch title when it changes
0.1.4 patch browser tab title to only contain the name of the show
0.1.3 ignore keypresses whilst typing
0.1.2 add next episode keybind: S or N (zoro/vibe/kiwi/gogo)
note: only available at the end of an episode. the stock keybind shift+N works at any time.
0.1.1 add update url
0.1.0 create gist: player auto-focus, skip keybind S (zoro/vibe/kiwi/gogo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment