Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
aniliyidogan committed Sep 24, 2016
0 parents commit 5c3f482
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## Github Activity ![Github Activity](/img/icon64.png "Github Activity")
![Github Activity](/img/github_activity.png "Github Activity")
17 changes: 17 additions & 0 deletions css/popup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
body{
padding: 10px;
min-width:400px;
min-height:400px;
}
#username{
padding-top: 5px;
font-size: 30px;
}
.chip{
color:#fff;
padding: 10px;
border-radius: 30px;
display: inline-block;
margin-bottom: 10px;
margin-right: 10px;
}
Binary file added icon.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 img/github_activity.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 img/icon64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"manifest_version": 2,

"name": "Github Activity",
"description": "activities of GitHub users",
"version": "0.1",

"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"https://api.github.com/users/*"
]
}
17 changes: 17 additions & 0 deletions popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html>
<head>
<title>Github Activity</title>
<link rel="stylesheet" href="css/popup.css">
<script src="popup.js"></script>
</head>
<body>
<center>
<img id="avatar">
<br>
<div id="username">
</div>
</center>
<div id="repo"></div>
</body>
</html>
42 changes: 42 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
chrome.tabs.getSelected(null,function(tab) {

var tablink = tab.url.split('/');
if (tablink[tablink.length - 1] === "") tablink.pop(); // url sonunda '/' olma durumu
if (tablink[tablink.length - 2] != "github.com") return; // farklı bir sayfada istek atma durumu

var xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.github.com/users/" + tablink[tablink.length-1] + "/events", true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {

var color = {"Watch": "#ffeb3b", "Push": "#4caf50", "PullRequest": "#03a9f4", "PullRequestReviewComment": "#0288d1",
"IssueComment": "#d32f2f", "Issues": "#f44336", "Create": "#ff5722", "Fork": "#9c27b0"}

data = JSON.parse(xhr.responseText)

document.getElementById("username").innerText = data[0]['actor']['login']
document.getElementById("avatar").src = data[0]['actor']['avatar_url']
document.getElementById("avatar").style = "width:60px;height:60px;border-radius:5px;"

div = document.getElementById("repo");

for(i = 0; i < 30; i++){
var type = data[i]['type'].split("Event")[0]

div.insertAdjacentHTML('beforeend',
"<div class='chip' style='background-color:"
+ color[type]
+ "'>"
+ type
+ "</div>")
div.insertAdjacentHTML('beforeend',
"<span style='font-size:16px'>"
+ data[i]['repo']['name']
+ "</span>"
+ "<br>")

}
}
}
xhr.send();
})

0 comments on commit 5c3f482

Please sign in to comment.