Created
January 8, 2025 18:42
-
-
Save wbamberg/af5981cbb0d25ae8928a240a12358660 to your computer and use it in GitHub Desktop.
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 Add MDN link | |
// @namespace http://tampermonkey.net/ | |
// @version 2025-01-08 | |
// @description Add MDN links to PR preview 404 pages | |
// @author You | |
// @match https://*.content.dev.mdn.mozit.cloud/* | |
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function matches() { | |
const h1 = document.querySelector("h1"); | |
return ( | |
h1 && | |
h1.textContent === "404 Not Found"); | |
} | |
if (matches()) { | |
const mdnLink = document.createElement("a"); | |
mdnLink.href = `https://developer.mozilla.org/${location.pathname}`; | |
mdnLink.textContent = "View on MDN"; | |
document.body.appendChild(mdnLink); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment