// ==UserScript== // @name GitHub HTML Preview // @version 1.0.6 // @description A userscript that adds preview links to HTML files // @license MIT // @author Rob Garrison // @namespace https://github.com/Mottie // @match https://github.com/* // @run-at document-idle // @grant none // @require https://greasyfork.org/scripts/28721-mutations/code/mutations.js?version=1108163 // @require https://greasyfork.org/scripts/398877-utils-js/code/utilsjs.js?version=1079637 // @icon https://github.githubassets.com/pinned-octocat.svg // @updateURL https://raw.githubusercontent.com/Mottie/GitHub-userscripts/master/github-html-preview.user.js // @downloadURL https://raw.githubusercontent.com/Mottie/GitHub-userscripts/master/github-html-preview.user.js // @supportURL https://github.com/Mottie/GitHub-userscripts/issues // ==/UserScript== /* global $ $$ on */ (() => { "use strict"; // Example page: https://github.com/codrops/DecorativeLetterAnimations // Source: https://github.com/htmlpreview/htmlpreview.github.com const prefix = "https://htmlpreview.github.io/?"; // html & htm extensions const regex = /\.html?$/; const link = document.createElement("a"); link.className = "ghhp-btn py-0 v-align-baseline tooltipped tooltipped-e"; link.setAttribute("aria-label", "Open in new tab"); link.target = "_blank"; link.innerHTML = ` `; link.style.marginRight = ".25rem"; function addLink(el) { const cell = el.closest(".js-navigation-item div[role='rowheader'] span"); if (cell && !$(".ghhp-btn", cell)) { const preview = link.cloneNode(true); preview.href = prefix + el.href; cell.prepend(preview); } } function init() { if ($("#files")) { const files = $("#files").parentElement; $$(".js-navigation-item div[role='rowheader'] .js-navigation-open", files).forEach(el => { if (regex.test(el.title)) { addLink(el); } }); } } on(document, "ghmo:container", () => { // init after a short delay to allow rendering of file list setTimeout(() => { init(); }, 200); }); init(); })(); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy