From 08f8839046e317c9d68ca796ce6088fcd85871b9 Mon Sep 17 00:00:00 2001 From: Zhenghao Zhang Date: Sat, 3 Oct 2026 15:35:23 +0800 Subject: [PATCH 1/2] fix: wait for repository description before loading neighbors --- extension/content.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/extension/content.js b/extension/content.js index ac695a6..f59d888 100644 --- a/extension/content.js +++ b/extension/content.js @@ -3,6 +3,7 @@ if (window.gitrecContentInitialized) return; window.gitrecContentInitialized = true; var itemId = null; +var repositoryDescription = null; var similarOffset = 0; var exploreContent = null; var loaded = false; @@ -14,6 +15,15 @@ function getRepositorySidebar() { return $('[class*="CodeViewSidebar-module__borderGrid"]').first(); } +function getRepositoryDescription() { + const sidebar = getRepositorySidebar(); + const description = sidebar.find('p[class*="SidebarAbout-module__description"]').first(); + if (description.length) return description.text().trim() || null; + // These elements mean About has rendered without a description. + if (sidebar.find('[class*="SidebarAbout-module__noDescription"], [class*="SidebarAbout-module__websiteRow"]').length) return ''; + return null; +} + function placeSimilarPanel() { const sidebar = getRepositorySidebar(); const languages = sidebar.find('h2').filter(function () { @@ -30,6 +40,7 @@ function initialize() { if (currentPath !== location.pathname) { currentPath = location.pathname; loaded = false; + repositoryDescription = null; similarOffset = 0; similarPanel = null; $("#similar-repositories").remove(); @@ -39,6 +50,8 @@ function initialize() { const repository = $('meta[name="octolytics-dimension-repository_nwo"]').attr('content'); if (splits.length >= 2 && repository && repository.toLowerCase() === splits.slice(0, 2).join('/').toLowerCase() && getRepositorySidebar().length > 0) { + repositoryDescription = getRepositoryDescription(); + if (repositoryDescription === null) return; loaded = true; itemId = splits[0] + ':' + splits[1]; // mark read @@ -57,18 +70,17 @@ function initialize() { } $(document).ready(initialize); -// Wait for React to render the sidebar, and handle navigation without a reload. +// Wait for React to render About, and handle navigation without a reload. new MutationObserver(function () { clearTimeout(refreshTimer); refreshTimer = setTimeout(initialize, 100); -}).observe(document.documentElement, { childList: true, subtree: true }); +}).observe(document.documentElement, { childList: true, characterData: true, subtree: true }); $(document).on('turbo:load turbo:render', initialize); $(window).on('popstate', initialize); function loadSimilarRepos() { const path = location.pathname; - const description = getRepositorySidebar().find('p[class*="SidebarAbout-module__description"]').first().text().trim(); - chrome.runtime.sendMessage({ neighbors: itemId, offset: similarOffset, description: description }, function (result) { + chrome.runtime.sendMessage({ neighbors: itemId, offset: similarOffset, description: repositoryDescription }, function (result) { if (location.pathname !== path) return; if (result.is_authenticated) { renderSimilarDiv(result); From 636e107f2a3d77261bec08bf2246db232943d769 Mon Sep 17 00:00:00 2001 From: Zhenghao Zhang Date: Sat, 3 Oct 2026 15:40:37 +0800 Subject: [PATCH 2/2] chore: bump browser extension version to 0.11 --- extension/manifest-firefox.json | 2 +- extension/manifest.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/extension/manifest-firefox.json b/extension/manifest-firefox.json index 1eee789..e43c6f6 100644 --- a/extension/manifest-firefox.json +++ b/extension/manifest-firefox.json @@ -1,7 +1,7 @@ { "name": "GitRec", "description": "A recommender system for GitHub repositories based on Gorse", - "version": "0.9", + "version": "0.11", "manifest_version": 3, "permissions": [ "scripting", diff --git a/extension/manifest.json b/extension/manifest.json index 238ac61..8db7e49 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -1,7 +1,7 @@ { "name": "GitRec", "description": "A recommender system for GitHub repositories based on Gorse", - "version": "0.9", + "version": "0.11", "manifest_version": 3, "permissions": [ "scripting", @@ -35,4 +35,4 @@ "background": { "service_worker": "background.js" } -} \ No newline at end of file +}