Created
August 17, 2023 08:43
-
-
Save sairajchouhan/a6b269eef1051c288b139584665de959 to your computer and use it in GitHub Desktop.
script to pin some repos in the sidebar of home page of Github
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
const repo_list = [ | |
"contentstack/UI-React", | |
"contentstack/visual-editor", | |
"contentstack/schema-form", | |
"contentstack/UI-E2E", | |
"contentstack/venus-components", | |
]; | |
document.addEventListener("DOMContentLoaded", () => { | |
setTimeout(() => { | |
const thing = document.querySelector("[aria-label='Repositories']"); | |
const div = document.createElement("div"); | |
div.innerHTML = ` | |
<h2 class="f5 mt-md-4 mt-0 mb-3">Your Repo List</h2> | |
<ul class="list-style-none" data-filterable-for="dashboard-repos-filter-left" data-filterable-type="substring"> | |
${get_repos(repo_list)} | |
</ul> | |
`; | |
thing.append(div); | |
}, 1000); | |
}); | |
function get_repos(repos) { | |
const username_repo_split = repos.map((repo) => repo.split("/")); | |
let markup = ""; | |
username_repo_split.forEach((repo) => { | |
markup += ` | |
<li class="public source no-description pb-2"> | |
<div class="width-full d-flex mt-2"> | |
<a data-hydro-click="{"event_type":"dashboard.click","payload":{"event_context":"REPOSITORIES","target":"REPOSITORY","record_id":618781741,"dashboard_context":"user","dashboard_version":2,"user_id":57995897,"metadata":null,"originating_url":"https://github.com/dashboard/my_top_repositories?location=left"}}" data-hydro-click-hmac="866fb3115c9cfaec9ced838f857b20713252791b60709468a9941f74b7192833" data-hovercard-type="repository" data-hovercard-url="/${repo[0]}/${repo[1]}/hovercard" class="color-fg-default lh-0 mb-2 markdown-title" href="/${repo[0]}/${repo[1]}"> | |
${repo[0]}<span class="color-fg-muted">/</span>${repo[1]} | |
</a> | |
</div> | |
</li> | |
`; | |
}); | |
return markup; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment