Created
March 11, 2025 12:21
-
-
Save tizee/d8bf498784e3d98c7b3708d944384b42 to your computer and use it in GitHub Desktop.
Cloudflare Docs - View Source Doc
This file contains 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 Cloudflare Docs - View Source Doc | |
// @namespace http://tampermonkey.net/ | |
// @version 2025-03-11 | |
// @description try to take over the world! | |
// @author tizee | |
// @match https://developers.cloudflare.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=cloudflare.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// 获取容器和需要复制的元素 | |
const container = document.querySelector("footer .meta"); | |
const el = container.querySelector('a[href^="https://github.com/cloudflare/cloudflare-docs/edit"]'); | |
if (el) { | |
// 复制元素 | |
const clonedEl = el.cloneNode(true); | |
// 修改复制的元素的 href 地址 | |
const newHref = el.href.replace( | |
/https:\/\/github\.com\/cloudflare\/cloudflare-docs\/edit\//, | |
"https://raw.githubusercontent.com/cloudflare/cloudflare-docs/refs/heads/" | |
); | |
clonedEl.href = newHref; | |
// 修改复制的元素的文本内容 | |
clonedEl.textContent = "View Source"; | |
// 将复制的元素追加到 container 中 | |
container.prepend(clonedEl); | |
console.debug("[CF DOC]", newHref); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment