Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions github-html-preview.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
const regex = /\.html?$/;

const link = document.createElement("a");
link.className = "ghhp-btn btn btn-sm py-0 px-1 tooltipped tooltipped-n";
link.className = "ghhp-btn btn btn-sm py-0 px-1 mx-1 v-align-baseline tooltipped tooltipped-n";
link.setAttribute("aria-label", "Open in new tab");
link.target = "_blank";
link.innerHTML = `
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="currentColor">
<svg class="octicon v-align-text-bottom" xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="currentColor">
<path d="M19 19H5V5h7V3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"/>
</svg>`;

function addLink(el) {
const cell = el.closest("td.content");
const cell = el.closest(".js-navigation-item div:nth-child(2) span");
if (!$(".ghhp-btn", cell)) {
const preview = link.cloneNode(true);
preview.href = prefix + el.href;
Expand All @@ -40,9 +40,9 @@
}

function init() {
if ($("table.files")) {
const files = $(".file-wrap");
$$("td.content .js-navigation-open", files).forEach(el => {
if ($(".js-details-container")) {
const files = $("#files").parentElement;
$$(".js-navigation-item div:nth-child(2) .js-navigation-open", files).forEach(el => {
if (regex.test(el.title)) {
addLink(el);
}
Expand Down