|
|
@ -211,9 +211,14 @@ function addBlameParentLinks() { |
|
|
|
|
|
|
|
function addReadmeEditButton() { |
|
|
|
const readmeContainer = $('#readme'); |
|
|
|
if (!readmeContainer.length) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const readmeName = $('#readme > h3').text().trim(); |
|
|
|
const path = $('.js-repo-root ~ .js-path-segment, .final-path').map((idx, el) => $(el).text()).get().join('/'); |
|
|
|
const currentBranch = $('.file-navigation .select-menu.left button.select-menu-button').attr('title'); |
|
|
|
const editHref = `/${repoUrl}/edit/${currentBranch}/${readmeName}`; |
|
|
|
const editHref = `/${repoUrl}/edit/${currentBranch}/${path ? `${path}/` : ''}${readmeName}`; |
|
|
|
const editButtonHtml = `<div id="refined-github-readme-edit-link">
|
|
|
|
<a href="${editHref}"> |
|
|
|
<svg class="octicon octicon-pencil" height="16" version="1.1" viewBox="0 0 14 16" width="14"><path d="M0 12v3h3l8-8-3-3L0 12z m3 2H1V12h1v1h1v1z m10.3-9.3l-1.3 1.3-3-3 1.3-1.3c0.39-0.39 1.02-0.39 1.41 0l1.59 1.59c0.39 0.39 0.39 1.02 0 1.41z"></path></svg> |
|
|
@ -384,7 +389,7 @@ document.addEventListener('DOMContentLoaded', () => { |
|
|
|
addBlameParentLinks(); |
|
|
|
} |
|
|
|
|
|
|
|
if (pageDetect.isRepoRoot()) { |
|
|
|
if (pageDetect.isRepoRoot() || pageDetect.isRepoTree()) { |
|
|
|
addReadmeEditButton(); |
|
|
|
} |
|
|
|
|
|
|
|