{"action":"created","comment":{"url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/pulls/comments/58302115","id":58302115,"diff_hunk":"@@ -64,67 +35,105 @@\n \t\treturn api;\n \t})();\n \n-\twindow.gitHubNotifCount = cb => {\n+\twindow.GitHubNotify.requestPermission = permission => {\n+\t\treturn new Promise(resolve => {\n+\t\t\tchrome.permissions.request({\n+\t\t\t\tpermissions: [permission]\n+\t\t\t}, granted => {\n+\t\t\t\twindow.GitHubNotify.settings.set(`${permission}_permission`, granted);\n+\t\t\t\tresolve(granted);\n+\t\t\t});\n+\t\t});\n+\t};\n+\n+\twindow.GitHubNotify.queryPermission = permission => {\n+\t\treturn new Promise(resolve => {\n+\t\t\tchrome.permissions.contains({\n+\t\t\t\tpermissions: [permission]\n+\t\t\t}, resolve);\n+\t\t});\n+\t};\n+\n+\twindow.GitHubNotify.request = (url, customHeaders) => {\n \t\tconst token = window.GitHubNotify.settings.get('oauthToken');\n-\t\tconst opts = {\n+\t\tif (!token) {\n+\t\t\treturn Promise.reject(new Error('missing token'));\n+\t\t}\n+\n+\t\tconst headers = Object.assign({\n \t\t\tAuthorization: `token ${token}`\n-\t\t};\n-\t\tconst query = [];\n-\t\tif (window.GitHubNotify.settings.get('useParticipatingCount')) {\n-\t\t\tquery.push('participating=true');\n+\t\t}, customHeaders);\n+\n+\t\treturn fetch(url, {headers});\n+\t};\n+\n+\twindow.GitHubNotify.getApiUrl = () => {\n+\t\tconst rootUrl = window.GitHubNotify.settings.get('rootUrl');\n+\n+\t\tif (/(^(https:\\/\\/)?(api\\.)?github\\.com)/.test(rootUrl)) {\n+\t\t\treturn 'https://api.github.com/notifications';\n \t\t}\n-\t\tquery.push('per_page=1');\n+\t\treturn `${rootUrl}api/v3/notifications`;\n+\t};\n \n-\t\tlet url = window.GitHubNotify.settings.get('rootUrl');\n+\twindow.GitHubNotify.getTabUrl = () => {\n+\t\tlet rootUrl = window.GitHubNotify.settings.get('rootUrl');\n \n-\t\tif (!token) {\n-\t\t\tcb(new Error('missing token'), null, window.GitHubNotify.defaults.interval);\n-\t\t\treturn;\n+\t\tif (/api.github.com\\/$/.test(rootUrl)) {","path":"extension/api.js","position":95,"original_position":95,"commit_id":"c431aca0df489829ee9f6beb03c4e14887a9a113","original_commit_id":"c431aca0df489829ee9f6beb03c4e14887a9a113","user":{"login":"gcochard","id":2836237,"avatar_url":"https://avatars.githubusercontent.com/u/2836237?v=3","gravatar_id":"","url":"https://api.github.com/users/gcochard","html_url":"https://github.com/gcochard","followers_url":"https://api.github.com/users/gcochard/followers","following_url":"https://api.github.com/users/gcochard/following{/other_user}","gists_url":"https://api.github.com/users/gcochard/gists{/gist_id}","starred_url":"https://api.github.com/users/gcochard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gcochard/subscriptions","organizations_url":"https://api.github.com/users/gcochard/orgs","repos_url":"https://api.github.com/users/gcochard/repos","events_url":"https://api.github.com/users/gcochard/events{/privacy}","received_events_url":"https://api.github.com/users/gcochard/received_events","type":"User","site_admin":false},"body":"Nevermind. Scrolled down and see that it was moved from below. This should work as-is.","created_at":"2016-04-03T00:15:29Z","updated_at":"2016-04-03T00:15:29Z","html_url":"https://github.com/sindresorhus/notifier-for-github-chrome/pull/66#discussion_r58302115","pull_request_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/pulls/66","_links":{"self":{"href":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/pulls/comments/58302115"},"html":{"href":"https://github.com/sindresorhus/notifier-for-github-chrome/pull/66#discussion_r58302115"},"pull_request":{"href":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/pulls/66"}}},"pull_request":{"url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/pulls/66","id":62671817,"html_url":"https://github.com/sindresorhus/notifier-for-github-chrome/pull/66","diff_url":"https://github.com/sindresorhus/notifier-for-github-chrome/pull/66.diff","patch_url":"https://github.com/sindresorhus/notifier-for-github-chrome/pull/66.patch","issue_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/issues/66","number":66,"state":"open","locked":false,"title":"Implement desktop notifications.","user":{"login":"YuriSolovyov","id":2168518,"avatar_url":"https://avatars.githubusercontent.com/u/2168518?v=3","gravatar_id":"","url":"https://api.github.com/users/YuriSolovyov","html_url":"https://github.com/YuriSolovyov","followers_url":"https://api.github.com/users/YuriSolovyov/followers","following_url":"https://api.github.com/users/YuriSolovyov/following{/other_user}","gists_url":"https://api.github.com/users/YuriSolovyov/gists{/gist_id}","starred_url":"https://api.github.com/users/YuriSolovyov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YuriSolovyov/subscriptions","organizations_url":"https://api.github.com/users/YuriSolovyov/orgs","repos_url":"https://api.github.com/users/YuriSolovyov/repos","events_url":"https://api.github.com/users/YuriSolovyov/events{/privacy}","received_events_url":"https://api.github.com/users/YuriSolovyov/received_events","type":"User","site_admin":false},"body":"This is another attempt to add desktop notifications based on work of @inikulin in #25.\r\nThe main feedback in original PR was about notification content and action we perform on notification click. \r\n\r\nWith minimal changes, I was able to make it look like so:\r\n![image](https://cloud.githubusercontent.com/assets/2168518/13728530/0e041fb2-e92d-11e5-974e-c7f0b58319fb.png)\r\n\r\nThough I'd like to purpose a bit different style:\r\n![image](https://cloud.githubusercontent.com/assets/2168518/13729060/8a6cecfa-e93c-11e5-84ca-e1ff402ac0c6.png)\r\n\r\nWith all that there are still some questions left:\r\n- what do we show if there are more than 1 notification?\r\n  - list notification? \r\n\r\n  ![image](https://developer.chrome.com/static/images/list_notification.png)\r\n - just say \"there are N notifications for you\" ? or \"there is `foo` and N-1 other notifications for you\"?\r\n\r\n- we need to somehow track last notification timestamp, so we don't show same thing several times.\r\n- on > 1 notification, where should click bring you?\r\n\r\n/cc @sindresorhus ","created_at":"2016-03-13T14:08:41Z","updated_at":"2016-04-03T00:15:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4c065e680cd474de88c94de4761c1673f14e4378","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/pulls/66/commits","review_comments_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/pulls/66/comments","review_comment_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/issues/66/comments","statuses_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/statuses/c431aca0df489829ee9f6beb03c4e14887a9a113","head":{"label":"YuriSolovyov:desk-notif","ref":"desk-notif","sha":"c431aca0df489829ee9f6beb03c4e14887a9a113","user":{"login":"YuriSolovyov","id":2168518,"avatar_url":"https://avatars.githubusercontent.com/u/2168518?v=3","gravatar_id":"","url":"https://api.github.com/users/YuriSolovyov","html_url":"https://github.com/YuriSolovyov","followers_url":"https://api.github.com/users/YuriSolovyov/followers","following_url":"https://api.github.com/users/YuriSolovyov/following{/other_user}","gists_url":"https://api.github.com/users/YuriSolovyov/gists{/gist_id}","starred_url":"https://api.github.com/users/YuriSolovyov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YuriSolovyov/subscriptions","organizations_url":"https://api.github.com/users/YuriSolovyov/orgs","repos_url":"https://api.github.com/users/YuriSolovyov/repos","events_url":"https://api.github.com/users/YuriSolovyov/events{/privacy}","received_events_url":"https://api.github.com/users/YuriSolovyov/received_events","type":"User","site_admin":false},"repo":{"id":53779876,"name":"notifier-for-github-chrome","full_name":"YuriSolovyov/notifier-for-github-chrome","owner":{"login":"YuriSolovyov","id":2168518,"avatar_url":"https://avatars.githubusercontent.com/u/2168518?v=3","gravatar_id":"","url":"https://api.github.com/users/YuriSolovyov","html_url":"https://github.com/YuriSolovyov","followers_url":"https://api.github.com/users/YuriSolovyov/followers","following_url":"https://api.github.com/users/YuriSolovyov/following{/other_user}","gists_url":"https://api.github.com/users/YuriSolovyov/gists{/gist_id}","starred_url":"https://api.github.com/users/YuriSolovyov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/YuriSolovyov/subscriptions","organizations_url":"https://api.github.com/users/YuriSolovyov/orgs","repos_url":"https://api.github.com/users/YuriSolovyov/repos","events_url":"https://api.github.com/users/YuriSolovyov/events{/privacy}","received_events_url":"https://api.github.com/users/YuriSolovyov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/YuriSolovyov/notifier-for-github-chrome","description":"Chrome/Opera extension - Displays your GitHub notifications unread count","fork":true,"url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome","forks_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/forks","keys_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/teams","hooks_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/hooks","issue_events_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/issues/events{/number}","events_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/events","assignees_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/assignees{/user}","branches_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/branches{/branch}","tags_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/tags","blobs_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/git/refs{/sha}","trees_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/statuses/{sha}","languages_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/languages","stargazers_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/stargazers","contributors_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/contributors","subscribers_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/subscribers","subscription_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/subscription","commits_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/commits{/sha}","git_commits_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/git/commits{/sha}","comments_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/comments{/number}","issue_comment_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/issues/comments{/number}","contents_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/contents/{+path}","compare_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/merges","archive_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/downloads","issues_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/issues{/number}","pulls_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/pulls{/number}","milestones_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/milestones{/number}","notifications_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/labels{/name}","releases_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/releases{/id}","deployments_url":"https://api.github.com/repos/YuriSolovyov/notifier-for-github-chrome/deployments","created_at":"2016-03-13T10:44:56Z","updated_at":"2016-03-26T14:30:45Z","pushed_at":"2016-04-02T09:23:30Z","git_url":"git://github.com/YuriSolovyov/notifier-for-github-chrome.git","ssh_url":"git@github.com:YuriSolovyov/notifier-for-github-chrome.git","clone_url":"https://github.com/YuriSolovyov/notifier-for-github-chrome.git","svn_url":"https://github.com/YuriSolovyov/notifier-for-github-chrome","homepage":"","size":1632,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"sindresorhus:master","ref":"master","sha":"0fb55d1c4d7702e25452f5ca4d5a2dcac7b4c842","user":{"login":"sindresorhus","id":170270,"avatar_url":"https://avatars.githubusercontent.com/u/170270?v=3","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"repo":{"id":18894771,"name":"notifier-for-github-chrome","full_name":"sindresorhus/notifier-for-github-chrome","owner":{"login":"sindresorhus","id":170270,"avatar_url":"https://avatars.githubusercontent.com/u/170270?v=3","gravatar_id":"","url":"https://api.github.com/users/sindresorhus","html_url":"https://github.com/sindresorhus","followers_url":"https://api.github.com/users/sindresorhus/followers","following_url":"https://api.github.com/users/sindresorhus/following{/other_user}","gists_url":"https://api.github.com/users/sindresorhus/gists{/gist_id}","starred_url":"https://api.github.com/users/sindresorhus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sindresorhus/subscriptions","organizations_url":"https://api.github.com/users/sindresorhus/orgs","repos_url":"https://api.github.com/users/sindresorhus/repos","events_url":"https://api.github.com/users/sindresorhus/events{/privacy}","received_events_url":"https://api.github.com/users/sindresorhus/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sindresorhus/notifier-for-github-chrome","description":"Chrome extension - Displays your GitHub notifications unread count","fork":false,"url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome","forks_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/forks","keys_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/teams","hooks_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/hooks","issue_events_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/issues/events{/number}","events_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/events","assignees_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/assignees{/user}","branches_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/branches{/branch}","tags_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/tags","blobs_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/git/refs{/sha}","trees_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/statuses/{sha}","languages_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/languages","stargazers_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/stargazers","contributors_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/contributors","subscribers_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/subscribers","subscription_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/subscription","commits_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/commits{/sha}","git_commits_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/git/commits{/sha}","comments_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/comments{/number}","issue_comment_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/issues/comments{/number}","contents_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/contents/{+path}","compare_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/merges","archive_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/downloads","issues_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/issues{/number}","pulls_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/pulls{/number}","milestones_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/milestones{/number}","notifications_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/labels{/name}","releases_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/releases{/id}","deployments_url":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/deployments","created_at":"2014-04-17T21:59:59Z","updated_at":"2016-03-29T18:07:10Z","pushed_at":"2016-04-02T14:11:30Z","git_url":"git://github.com/sindresorhus/notifier-for-github-chrome.git","ssh_url":"git@github.com:sindresorhus/notifier-for-github-chrome.git","clone_url":"https://github.com/sindresorhus/notifier-for-github-chrome.git","svn_url":"https://github.com/sindresorhus/notifier-for-github-chrome","homepage":"","size":1684,"stargazers_count":228,"watchers_count":228,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":43,"mirror_url":null,"open_issues_count":12,"forks":43,"open_issues":12,"watchers":228,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/pulls/66"},"html":{"href":"https://github.com/sindresorhus/notifier-for-github-chrome/pull/66"},"issue":{"href":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/issues/66"},"comments":{"href":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/issues/66/comments"},"review_comments":{"href":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/pulls/66/comments"},"review_comment":{"href":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/pulls/66/commits"},"statuses":{"href":"https://api.github.com/repos/sindresorhus/notifier-for-github-chrome/statuses/c431aca0df489829ee9f6beb03c4e14887a9a113"}}}}