userscripts/randompedia.js

23 lines
654 B
JavaScript
Raw Normal View History

2024-05-03 14:57:27 +00:00
// ==UserScript==
// @name Randompedia
// @namespace https://spookyinternet.com/
// @version 2024-05-03
2024-05-03 17:23:54 +00:00
// @description Random wiki pages in 1-click.
2024-05-03 14:57:27 +00:00
// @author Nick Chambers
// @match https://*.wikipedia.org/wiki/*
2024-05-03 17:23:54 +00:00
// @match https://rosettacode.org/wiki/*
2024-05-03 14:57:27 +00:00
// ==/UserScript==
(function() {
"use strict";
2024-05-03 17:23:54 +00:00
const url = new URL(window.location)
2024-05-03 14:57:27 +00:00
const button = document.createElement("a");
button.innerText = "Random Page!";
2024-05-03 17:23:54 +00:00
button.href = `https://${url.hostname}/wiki/Special:Random`;
2024-05-03 14:57:27 +00:00
const search = document.getElementById("p-search");
search.parentNode.insertBefore(button, search.nextSibling);
})();