Generalize random wiki page linker

This commit is contained in:
Nick Chambers 2024-05-03 12:23:54 -05:00
parent e4244d78c4
commit 9a63bf6ff8
1 changed files with 5 additions and 3 deletions

View File

@ -2,18 +2,20 @@
// @name Randompedia // @name Randompedia
// @namespace https://spookyinternet.com/ // @namespace https://spookyinternet.com/
// @version 2024-05-03 // @version 2024-05-03
// @description Random wikipedia pages in 1-click. // @description Random wiki pages in 1-click.
// @author Nick Chambers // @author Nick Chambers
// @match https://*.wikipedia.org/wiki/* // @match https://*.wikipedia.org/wiki/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=wikipedia.org // @match https://rosettacode.org/wiki/*
// ==/UserScript== // ==/UserScript==
(function() { (function() {
"use strict"; "use strict";
const url = new URL(window.location)
const button = document.createElement("a"); const button = document.createElement("a");
button.innerText = "Random Page!"; button.innerText = "Random Page!";
button.href = "https://en.wikipedia.org/wiki/Special:Random"; button.href = `https://${url.hostname}/wiki/Special:Random`;
const search = document.getElementById("p-search"); const search = document.getElementById("p-search");
search.parentNode.insertBefore(button, search.nextSibling); search.parentNode.insertBefore(button, search.nextSibling);