Random Password Generator

Generate secure random password

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Random Password Generator
// @namespace    https://openuserjs.org/users/burn
// @version      20260207
// @description  Generate secure random password
// @copyright    2026, burn (https://openuserjs.org//users/burn)
// @license      MIT
// @match        *://*/*
// @include      *
// @grant        GM_registerMenuCommand
// @grant        GM.registerMenuCommand
// @grant        GM_setClipboard
// @grant        GM.setClipboard
// ==/UserScript==

// ==OpenUserJS==
// @author burn
// ==/OpenUserJS==

/*jshint esversion: 8 */ 
(function() {
    'use strict';
    const DBG = false;
    const SCRIPT = GM_info.script.name;
    let log = (str) => {
        DBG && console.log(GM_info.script.name + " | " + str);
    };

    function secureRandomIndex(max) {
        const range = 0xFFFFFFFF;
        const limit = range - (range % max);
        const buf = new Uint32Array(1);

        do {
            crypto.getRandomValues(buf);
        } while (buf[0] >= limit);

        return buf[0] % max;
    }

    function pick(str) {
        return str[secureRandomIndex(str.length)];
    }

    Object.defineProperty(Array.prototype, "shuffle", {
        value: function() {
            for (let i = this.length - 1; i > 0; i--) {
                const j = secureRandomIndex(i + 1);
                [this[i], this[j]] = [this[j], this[i]];
            }
            return this;
        },
        enumerable: false
    });

    function generatePassword() {
        const LEN = 19;
        const LOWER = "abcdefghijkmnopqrstuvwxyz";
        const UPPER = "ABCDEFGHJKLMNPQRSTUVWXYZ";
        const NUM = "23456789";
        const SYM = "!@#$%^&*()-_=+[]{};:,.<>?";

        const ALL = LOWER + UPPER + NUM + SYM;

        const result = new Array(
            pick(LOWER),
            pick(UPPER),
            pick(NUM),
            pick(SYM)
        );

        for (let i = result.length; i < LEN; i++) {
            result.push(pick(ALL));
            result.shuffle();
        }

        if (typeof GM_setClipboard !== "undefined") {
            GM_setClipboard(result.join(""), "text");
        } else if (typeof GM !== "undefined" && GM.setClipboard) {
            GM.setClipboard(result.join(""), "text");
        }
    }

    if (typeof GM_registerMenuCommand !== "undefined") {
        GM_registerMenuCommand("Generate Secure Password", generatePassword);
    } else if (typeof GM !== "undefined" && GM.registerMenuCommand) {
        GM.registerMenuCommand("Generate Secure Password", generatePassword);
    }
})();