Greasy Fork

Greasy Fork is available in English.

Skribbl / Skribbl.io QOL

Quality of life improvements for Skribbl.io

当前为 2022-05-22 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Skribbl / Skribbl.io QOL
// @version      0.3
// @description  Quality of life improvements for Skribbl.io
// @author       4TSOS
// @match        http*://skribbl.io/*
// @run-at       document-idle
// @icon         https://www.google.com/s2/favicons?sz=64&domain=skribbl.io
// @namespace    http://greasyfork.icu/users/784494
// ==/UserScript==

(function() {
    'use strict';
    qol_setup();
    qol_info();
    qol_buttons();
    const inputChat = document.querySelector("#inputChat");
    const inputName = document.querySelector("#inputName");
    const header = document.querySelector("body > div.container-fluid > div.header");
    const timer = document.querySelector("#timer");
    const _currentWord = document.querySelector("#currentWord");
    var currentWord = null;
    function qol_setup() {
        document.body.addEventListener('keydown', function() {
            inputChat.focus();
            inputName.focus();
        });
    };
    function qol_info() {
        setInterval(function() {
            document.title = `(${timer.innerHTML}s) Skribbl.io`;
        }, 500);
    };
    function qol_buttons() {
        const qolButtonsList = document.createElement("div");
        const qolWordToggle = document.createElement("button");
        const qolClearChat = document.createElement("button");
        qolButtonsList.id = "qol-buttons-list";
        qolButtonsList.style.display = "flex";
        qolButtonsList.style.justifyContent = "center";
        qolButtonsList.style.flexDirection = "row";
        qolWordToggle.id = "qol-word-toggle";
        qolWordToggle.innerHTML = "Hide Word";
        qolWordToggle.onclick = function() {
            if (!document.querySelector("#currentWord").style.visibility) {
                document.querySelector("#currentWord").style.visibility = "hidden";
                document.querySelector("#qol-word-toggle").innerHTML = "Show Word";
                return
            };
            if (document.querySelector("#currentWord").style.visibility) {
                document.querySelector("#currentWord").removeAttribute("style");
                document.querySelector("#qol-word-toggle").innerHTML = "Hide Word";
                return
            };
        };
        qolClearChat.id = "qol-clear-chat";
        qolClearChat.innerHTML = "Clear Chat";
        qolClearChat.onclick = function() {
            var chatMessages = document.querySelectorAll("#boxMessages > *");
            chatMessages.forEach(function(message) {
                message.remove();
            });
        };
        qolButtonsList.appendChild(qolWordToggle);
        qolButtonsList.appendChild(qolClearChat);
        document.querySelector("body > div.container-fluid > div.header").appendChild(qolButtonsList);
    };
})();