Fucking with people

inserts random hair spaces into your toots to fuck with people

当前为 2018-07-03 提交的版本,查看 最新版本

// ==UserScript==
// @name         Fucking with people
// @namespace    https://github.com/ashkitten
// @version      1.0.1
// @description  inserts random hair spaces into your toots to fuck with people
// @author       ashkitten
// @match        https://sleeping.town/*
// @grant        none
// ==/UserScript==

/* jshint esversion: 6 */

(function() {
    'use strict';

    // callback function to execute when mutations are observed
    // we can't use an arrow function here because we need the `this` object
    new MutationObserver(function(mutations) {
        // target the composer textarea
        let textarea = document.querySelector(".composer--textarea .textarea");
        // check if it exists
        if (textarea) {
            textarea.addEventListener("input", e => {
                // check if we're inserting a single character
                if (e.data !== null && e.data.length === 1) {
                    // a 1 in 5 chance works pretty well
                    if (Math.random() < 0.2) {
                        // insert a hair space
                        let cursor = textarea.selectionStart;
                        textarea.value = `${textarea.value.slice(0, cursor)}\u200a${textarea.value.slice(cursor)}`;
                        textarea.setSelectionRange(cursor + 1, cursor + 1);
                    }
                }
            });
            // disconnect the MutationObserver so it won't get called again
            this.disconnect();
        }
    }).observe(document.body, { childList: true, subtree: true });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址