Last active
October 24, 2025 23:20
-
-
Save SpiritAxolotl/aa4ed8721b0f386fb3f4f0aca7d02d25 to your computer and use it in GitHub Desktop.
internet phonebook dial-a-site random button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Random Dial | |
| // @namespace https://spax.zone | |
| // @version 2025-09-13 | |
| // @description dials a random person on the internet phonebook :3 | |
| // @author Spax | |
| // @match https://internetphonebook.net/* | |
| // @icon https://icons.duckduckgo.com/ip2/internetphonebook.net.ico | |
| // @grant unsafeWindow | |
| // ==/UserScript== | |
| const mainRandomDial = async () => { | |
| const pressDelay = 200; //in ms | |
| const randomDial = document.createElement(`button`); | |
| randomDial.type = "button"; | |
| randomDial.textContent = "random"; | |
| const dialPad = document.querySelector(`#dial-pad`); | |
| const siteNumber = document.querySelector(`#site-number`); | |
| const buttons = {}; | |
| for (const button of [...dialPad.children]) { | |
| buttons[button.textContent] = button; | |
| } | |
| const dialForm = document.querySelector(`#dial-form`); | |
| const db = await fetchDatabase(); | |
| dialForm.appendChild(randomDial); | |
| const getDigits = (num) => { | |
| return (num+"").split(``).map(n=>+n); | |
| }; | |
| const dialRandomNumber = (digits=[], i=0) => { | |
| if (i < digits.length) { | |
| buttons[digits[i]].click(); | |
| setTimeout(dialRandomNumber, pressDelay, digits, i+1); | |
| } else buttons["call"].click(); | |
| }; | |
| randomDial.addEventListener("click", event => { | |
| if (siteNumber.value !== "") siteNumber.value = ""; | |
| const rand = Math.floor(Math.random() * db.length) + 1; | |
| console.log("Random dial: " + rand); | |
| dialRandomNumber(getDigits((rand+"").padStart(3, "0"))); | |
| }); | |
| }; | |
| if (document.querySelector(`#phone`) !== null) | |
| mainRandomDial(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment