Skip to content

Instantly share code, notes, and snippets.

@sairajchouhan
Created August 17, 2023 08:43
Show Gist options
  • Save sairajchouhan/a6b269eef1051c288b139584665de959 to your computer and use it in GitHub Desktop.
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
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="{&quot;event_type&quot;:&quot;dashboard.click&quot;,&quot;payload&quot;:{&quot;event_context&quot;:&quot;REPOSITORIES&quot;,&quot;target&quot;:&quot;REPOSITORY&quot;,&quot;record_id&quot;:618781741,&quot;dashboard_context&quot;:&quot;user&quot;,&quot;dashboard_version&quot;:2,&quot;user_id&quot;:57995897,&quot;metadata&quot;:null,&quot;originating_url&quot;:&quot;https://github.com/dashboard/my_top_repositories?location=left&quot;}}" 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