Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Github Repository Analyzer #2484

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
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
Binary file added Github Repository Analyzer/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Github Repository Analyzer/icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Github Repository Analyzer/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions Github Repository Analyzer/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Github Repository Analyzer</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Github Repository Analyzer</h1>
<form id="repo-form">
<label for="owner">Repository Owner:</label>
<input type="text" id="owner" name="owner" required>

<label for="repo">Repository Name:</label>
<input type="text" id="repo" name="repo" required>

<button type="submit">Analyzer</button>
</form>

<div id="results"></div>
</div>
<script src="script.js"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions Github Repository Analyzer/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"manifest_version": 3,
"name": "GitHub Repository Analyzer",
"version": "1.0",
"description": "Analyze GitHub repositories from your browser.",
"permissions": [
"activeTab"
],
"host_permissions": [
"https://api.github.com/*"
],
"action": {
"default_popup": "index.html",
"default_icon": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
}
},
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
}
}

45 changes: 45 additions & 0 deletions Github Repository Analyzer/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
document.addEventListener('DOMContentLoaded', () => {
const form = document.getElementById('repo-form');
const resultsDiv = document.getElementById('results');

if (!form || !resultsDiv) {
console.error('Form or results container not found.');
return;
}

form.addEventListener('submit', async (event) => {
event.preventDefault();

const ownerInput = document.getElementById('owner');
const repoInput = document.getElementById('repo');

if (!ownerInput || !repoInput) {
console.error('Owner or repo input fields not found.');
return;
}

const owner = ownerInput.value.trim(); //ownerInput if null then error
const repo = repoInput.value.trim(); //repoInput if null then error

resultsDiv.innerHTML = 'Loading...';

try {
const response = await fetch(`https://api.github.com/repos/${owner}/${repo}`);
if (!response.ok) throw new Error('Repository not found');

const repoData = await response.json();

resultsDiv.innerHTML = `
<h2>Repository Details</h2>
<p><strong>Name:</strong> ${repoData.name}</p>
<p><strong>Description:</strong> ${repoData.description || 'No description available'}</p>
<p><strong>Stars:</strong> ${repoData.stargazers_count}</p>
<p><strong>Forks:</strong> ${repoData.forks_count}</p>
<p><strong>Open Issues:</strong> ${repoData.open_issues_count}</p>
<p><strong>Language:</strong> ${repoData.language || 'Not specified'}</p>
`;
} catch (error) {
resultsDiv.innerHTML = `<p>Error: ${error.message}</p>`;
}
});
});
48 changes: 48 additions & 0 deletions Github Repository Analyzer/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
body {
font-family: Arial, sans-serif;
width: 300px;
margin: 0;
padding: 0;
}

.container {
padding: 20px;
}

h1 {
font-size: 16px;
margin-bottom: 10px;
}

form {
display: flex;
flex-direction: column;
}

label {
margin: 5px 0;
}

input {
padding: 5px;
margin-bottom: 10px;
border: 1px solid #ddd;
border-radius: 4px;
}

button {
padding: 5px;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}

button:hover {
background-color: #0056b3;
}

#results {
margin-top: 10px;
}
Loading