userscripts/randompedia.js

26 lines
757 B
JavaScript

// ==UserScript==
// @name Randompedia
// @namespace https://spookyinternet.com/
// @version 2024-05-03
// @description Random wiki pages in 1-click.
// @author Nick Chambers
// @match https://*.wikipedia.org/wiki/*
// @match https://rosettacode.org/wiki/*
// ==/UserScript==
(function() {
"use strict";
const url = new URL(window.location)
const button = document.createElement("a");
button.innerText = "Random Page!";
button.href = `https://${url.hostname}/wiki/Special:Random`;
button.style.display = "block";
button.style.width = "40%";
button.style["text-align"] = "left";
const search = document.getElementById("p-search");
search.parentNode.insertBefore(button, search.nextSibling);
})();