Blur the VM screen with a click of a added button whenever something discomforting comes up on the VM Screen. The button also supports all CollabVM themes, and this script contains some extra configurable buttons within it's code that you can freely edit.
当前为
// ==UserScript==
// @name VM 0b0t Easy Screen Blur
// @namespace http://computernewb.com/
// @version 1.1
// @description Blur the VM screen with a click of a added button whenever something discomforting comes up on the VM Screen. The button also supports all CollabVM themes, and this script contains some extra configurable buttons within it's code that you can freely edit.
// @author guest59511
// @match https://computernewb.com/collab-vm*
// @match http://computernewb.com/collab-vm*
// @icon https://www.google.com/s2/favicons?sz=64&domain=computernewb.com
// @grant none
// @license GPT-3.0
// ==/UserScript==
(function() {
'use strict';
// defining some variables & settings
const vmscreen = document.getElementById("display"); // variable so we can retrieve the vm screen element
const adminbtns = document.getElementById("admin-btns");
const btns = document.getElementById("btns") || document.getElementById("vote-stats").nextSibling; // so we can add the blur button in
var isblurred = false; // says if the vm screen is blurred or not
const blursize = 25; // Allows to adjust the blur size. Default is 25px.
const showonnon0b0tvm = true; // Allows you to show the blur button even when not on a 0b0t VM.
const bluronvmjoin = false; // Allows you to immediately blur the VM screen upon joining. Does not apply to non-0b0t VMs.
var blurbtn; // needed to display the blur button
// multi-theme support
try {
if ($.fn.tooltip.Constructor.VERSION.startsWith('5')) { // detect bootstrap 5
var bt5 = true;
}
} catch (e) {
if (document.getElementById("turn-btn").classList.contains("ui")) { // detect beta theme
var betatheme = true;
}
}
console.log("Welcome to \"VM 0b0t Easy Screen Blur!\"!");
// adding the button
var btnInterval = setInterval(function() {
if (window.vmName != null) {
if (!showonnon0b0tvm) {
if (window.vmName == "vm0b0t") {
blurbtn = document.createElement("button"); // the button that makes the dropdown toggable
blurbtn.classList.add("btn", "btn-default");
if (bt5) {
blurbtn.classList.add("btn-light");
} else if (betatheme) {
blurbtn.classList.add("ui", "button");
}
blurbtn.type = "button";
blurbtn.id = "blur-screen-btn";
if (betatheme) {
blurbtn.innerHTML = "<i class='times circle outline icon'></i> Blur VM Screen";
} else {
blurbtn.innerHTML = "Blur VM Screen";
}
blurbtn.onclick = blurvmscreen;
btns.appendChild(blurbtn);
let btnspacing = document.createElement("span"); // if the user has another userscript which also add buttons, we want to add spacing between the auto-turn dropdown button and the userscript's button
btnspacing.textContent = " ";
btns.insertBefore(btnspacing, adminbtns);
clearInterval(btnInterval);
}
} else {
blurbtn = document.createElement("button"); // the button that makes the dropdown toggable
blurbtn.classList.add("btn", "btn-default");
if (bt5) {
blurbtn.classList.add("btn-light");
} else if (betatheme) {
blurbtn.classList.add("ui", "button");
}
blurbtn.type = "button";
blurbtn.id = "blur-screen-btn";
if (betatheme) {
blurbtn.innerHTML = "<i class='times circle outline icon'></i> Blur VM Screen";
} else {
blurbtn.innerHTML = "Blur VM Screen";
}
blurbtn.onclick = blurvmscreen;
btns.appendChild(blurbtn);
let btnspacing = document.createElement("span"); // if the user has another userscript which also add buttons, we want to add spacing between the auto-turn dropdown button and the userscript's button
btnspacing.textContent = " ";
btns.insertBefore(btnspacing, adminbtns);
clearInterval(btnInterval);
}
}
}, 0);
// adding some functions
function blurvmscreen() {
if (!isblurred) {
vmscreen.style.filter = `blur(${blursize}px)`;
if (betatheme) {
blurbtn.innerHTML = "<i class='times circle icon'></i> Unblur VM Screen";
} else {
blurbtn.classList.add("active");
blurbtn.innerHTML = "Unblur VM Screen";
}
isblurred = true;
} else {
vmscreen.style.filter = "blur(0px)";
if (betatheme) {
blurbtn.innerHTML = "<i class='times circle outline icon'></i> Blur VM Screen";
} else {
blurbtn.classList.remove("active");
blurbtn.innerHTML = "Blur VM Screen";
}
isblurred = false;
}
}
})();