Last active
December 18, 2025 12:56
-
-
Save bogorad/3a21908ec0c8c9f06e2da5b77a3927a2 to your computer and use it in GitHub Desktop.
userscript for TamperMonkey and the like - redirect wikipedia to grokipedia
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 Wikipedia to Grokipedia Redirector | |
| // @namespace http://tampermonkey.net/ | |
| // @version 1.0 | |
| // @description Redirect to Grokipedia if page exists | |
| // @author You | |
| // @match https://en.wikipedia.org/wiki/* | |
| // @connect grokipedia.com | |
| // @grant GM_xmlhttpRequest | |
| // @run-at document-start | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| // Extract page name from URL | |
| const match = window.location.pathname.match(/^\/wiki\/(.+)$/); | |
| if (!match) return; | |
| const pageName = match[1]; | |
| const grokipediaUrl = `https://grokipedia.com/page/${pageName}`; | |
| // Check if page exists on Grokipedia | |
| GM_xmlhttpRequest({ | |
| method: 'HEAD', | |
| url: grokipediaUrl, | |
| onload: function(response) { | |
| if (response.status === 200) { | |
| window.location.replace(grokipediaUrl); | |
| } | |
| }, | |
| onerror: function(response) { | |
| // Page doesn't exist or error occurred, stay on Wikipedia | |
| console.log('Grokipedia check failed:', response.statusText); | |
| }, | |
| ontimeout: function() { | |
| console.log('Grokipedia check timed out'); | |
| }, | |
| timeout: 3000 // 3 second timeout | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment