{"action":"created","comment":{"url":"https://api.github.com/repos/eight04/ansi-viewer/pulls/comments/196930744","pull_request_review_id":130574733,"id":196930744,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5NjkzMDc0NA==","diff_hunk":"@@ -0,0 +1,132 @@\n+/* eslint-env webextensions */\n+\n+const VALID_CONTENT_TYPE = new Set([\n+  \"text/plain\", \"text/ansi\", \"text/x-ansi\"\n+]);\n+\n+browser.webRequest.onHeadersReceived.addListener(details => {\n+  if (details.method == \"POST\") {\n+    return;\n+  }\n+  if (details.statusCode !== 200) {\n+    return;\n+  }\n+  const header = details.responseHeaders.find(h => h.name == \"Content-Type\");\n+  if (!header) {\n+    return;\n+  }\n+  const url = new URL(details.url);\n+  if (/\\.(ans|bbs|ansi)$/.test(url.pathname) && VALID_CONTENT_TYPE.has(header.value)) {\n+    // FIXME: handle file requests\n+    // https://bugzilla.mozilla.org/show_bug.cgi?id=1341341\n+    viewAsANSI(details.tabId, details.url);\n+    return {responseHeaders: details.responseHeaders.filter(h => h !== header)};\n+  }\n+}, {\n+  urls: [\"<all_urls>\"],\n+  types: [\"main_frame\"]\n+}, [\"blocking\", \"responseHeaders\"]);\n+\n+const ansiWorker = createANSIWorker();\n+\n+const METHODS = {\n+  compileANSI: ansiWorker.compileANSI\n+};\n+\n+browser.runtime.onMessage.addListener(message => {\n+  if (!METHODS[message.method]) {\n+    return;\n+  }\n+  return METHODS[message.method](message.data)\n+    .catch(err => {\n+      console.error(err); // eslint-disable-line\n+      throw err;\n+    });\n+});\n+\n+function createANSIWorker() {\n+  let worker;\n+  let error;\n+  let nextId = 0;\n+  const waitForResponse = new Map;\n+  return {compileANSI};\n+  \n+  function init() {\n+    worker = new Worker(\"/js/ansi-worker.js\");\n+    worker.addEventListener(\"error\", onError);\n+    worker.addEventListener(\"message\", onMessage);\n+  }\n+  \n+  function compileANSI(data) {\n+    if (!worker) {\n+      init();\n+    }\n+    return new Promise((resolve, reject) => {\n+      if (error) {\n+        reject(error);\n+        return;\n+      }\n+      const requestId = nextId++;\n+      worker.postMessage({requestId, data});\n+      waitForResponse.set(requestId, {resolve, reject});\n+    });\n+  }\n+  \n+  function onError(err) {\n+    error = err;\n+  }\n+  \n+  function onMessage(e) {\n+    if (e.data.error) {\n+      waitForResponse.get(e.data.requestId).reject(e.data.data);\n+    } else {\n+      waitForResponse.get(e.data.requestId).resolve(e.data.data);\n+    }\n+    waitForResponse.delete(e.data.requestId);\n+  }\n+}\n+\n+const waitForUpdate = new Set;\n+function viewAsANSI(tabId, url) {\n+  init();\n+  \n+  function init() {\n+    if (waitForUpdate.has(tabId)) {\n+      return;\n+    }\n+    browser.tabs.onUpdated.addListener(onUpdated);\n+    browser.tabs.onRemoved.addListener(onRemoved);\n+    waitForUpdate.add(tabId);\n+  }\n+  \n+  function uninit() {\n+    browser.tabs.onUpdated.removeListener(onUpdated);\n+    browser.tabs.onRemoved.removeListener(onRemoved);\n+    waitForUpdate.delete(tabId);\n+  }\n+  \n+  function onUpdated(_tabId, changeInfo, tab) {\n+    if (_tabId !== tabId || tab.url !== url) {\n+      return;\n+    }\n+    browser.tabs.executeScript(tabId, {\n+      file: \"/js/browser-polyfill.min.js\"","path":"src/background.js","position":113,"original_position":113,"commit_id":"2c292ba43ac4f2c35b8aa3e4a5db2a7ca69f18ad","original_commit_id":"2c292ba43ac4f2c35b8aa3e4a5db2a7ca69f18ad","user":{"login":"eight04","id":1324510,"node_id":"MDQ6VXNlcjEzMjQ1MTA=","avatar_url":"https://avatars2.githubusercontent.com/u/1324510?v=4","gravatar_id":"","url":"https://api.github.com/users/eight04","html_url":"https://github.com/eight04","followers_url":"https://api.github.com/users/eight04/followers","following_url":"https://api.github.com/users/eight04/following{/other_user}","gists_url":"https://api.github.com/users/eight04/gists{/gist_id}","starred_url":"https://api.github.com/users/eight04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eight04/subscriptions","organizations_url":"https://api.github.com/users/eight04/orgs","repos_url":"https://api.github.com/users/eight04/repos","events_url":"https://api.github.com/users/eight04/events{/privacy}","received_events_url":"https://api.github.com/users/eight04/received_events","type":"User","site_admin":false},"body":"Import the file array from manifest.json.","created_at":"2018-06-20T20:26:20Z","updated_at":"2018-06-20T20:34:04Z","html_url":"https://github.com/eight04/ansi-viewer/pull/10#discussion_r196930744","pull_request_url":"https://api.github.com/repos/eight04/ansi-viewer/pulls/10","author_association":"OWNER","_links":{"self":{"href":"https://api.github.com/repos/eight04/ansi-viewer/pulls/comments/196930744"},"html":{"href":"https://github.com/eight04/ansi-viewer/pull/10#discussion_r196930744"},"pull_request":{"href":"https://api.github.com/repos/eight04/ansi-viewer/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/eight04/ansi-viewer/pulls/10","id":196258935,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2MjU4OTM1","html_url":"https://github.com/eight04/ansi-viewer/pull/10","diff_url":"https://github.com/eight04/ansi-viewer/pull/10.diff","patch_url":"https://github.com/eight04/ansi-viewer/pull/10.patch","issue_url":"https://api.github.com/repos/eight04/ansi-viewer/issues/10","number":10,"state":"open","locked":false,"title":"3.0 Rewrite","user":{"login":"eight04","id":1324510,"node_id":"MDQ6VXNlcjEzMjQ1MTA=","avatar_url":"https://avatars2.githubusercontent.com/u/1324510?v=4","gravatar_id":"","url":"https://api.github.com/users/eight04","html_url":"https://github.com/eight04","followers_url":"https://api.github.com/users/eight04/followers","following_url":"https://api.github.com/users/eight04/following{/other_user}","gists_url":"https://api.github.com/users/eight04/gists{/gist_id}","starred_url":"https://api.github.com/users/eight04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eight04/subscriptions","organizations_url":"https://api.github.com/users/eight04/orgs","repos_url":"https://api.github.com/users/eight04/repos","events_url":"https://api.github.com/users/eight04/events{/privacy}","received_events_url":"https://api.github.com/users/eight04/received_events","type":"User","site_admin":false},"body":"Fixes #8.\r\n\r\nTodos:\r\n\r\n* [ ] Context menu.\r\n* [ ] Hotkey.","created_at":"2018-06-20T20:13:25Z","updated_at":"2018-06-20T20:34:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f24451a2d774ddd601fdb87dd5374c1e593efb6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/eight04/ansi-viewer/pulls/10/commits","review_comments_url":"https://api.github.com/repos/eight04/ansi-viewer/pulls/10/comments","review_comment_url":"https://api.github.com/repos/eight04/ansi-viewer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/eight04/ansi-viewer/issues/10/comments","statuses_url":"https://api.github.com/repos/eight04/ansi-viewer/statuses/2c292ba43ac4f2c35b8aa3e4a5db2a7ca69f18ad","head":{"label":"eight04:dev-rollup","ref":"dev-rollup","sha":"2c292ba43ac4f2c35b8aa3e4a5db2a7ca69f18ad","user":{"login":"eight04","id":1324510,"node_id":"MDQ6VXNlcjEzMjQ1MTA=","avatar_url":"https://avatars2.githubusercontent.com/u/1324510?v=4","gravatar_id":"","url":"https://api.github.com/users/eight04","html_url":"https://github.com/eight04","followers_url":"https://api.github.com/users/eight04/followers","following_url":"https://api.github.com/users/eight04/following{/other_user}","gists_url":"https://api.github.com/users/eight04/gists{/gist_id}","starred_url":"https://api.github.com/users/eight04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eight04/subscriptions","organizations_url":"https://api.github.com/users/eight04/orgs","repos_url":"https://api.github.com/users/eight04/repos","events_url":"https://api.github.com/users/eight04/events{/privacy}","received_events_url":"https://api.github.com/users/eight04/received_events","type":"User","site_admin":false},"repo":{"id":57025522,"node_id":"MDEwOlJlcG9zaXRvcnk1NzAyNTUyMg==","name":"ansi-viewer","full_name":"eight04/ansi-viewer","owner":{"login":"eight04","id":1324510,"node_id":"MDQ6VXNlcjEzMjQ1MTA=","avatar_url":"https://avatars2.githubusercontent.com/u/1324510?v=4","gravatar_id":"","url":"https://api.github.com/users/eight04","html_url":"https://github.com/eight04","followers_url":"https://api.github.com/users/eight04/followers","following_url":"https://api.github.com/users/eight04/following{/other_user}","gists_url":"https://api.github.com/users/eight04/gists{/gist_id}","starred_url":"https://api.github.com/users/eight04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eight04/subscriptions","organizations_url":"https://api.github.com/users/eight04/orgs","repos_url":"https://api.github.com/users/eight04/repos","events_url":"https://api.github.com/users/eight04/events{/privacy}","received_events_url":"https://api.github.com/users/eight04/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eight04/ansi-viewer","description":"A Firefox addon which let you view .ans file in the browser.","fork":false,"url":"https://api.github.com/repos/eight04/ansi-viewer","forks_url":"https://api.github.com/repos/eight04/ansi-viewer/forks","keys_url":"https://api.github.com/repos/eight04/ansi-viewer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eight04/ansi-viewer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eight04/ansi-viewer/teams","hooks_url":"https://api.github.com/repos/eight04/ansi-viewer/hooks","issue_events_url":"https://api.github.com/repos/eight04/ansi-viewer/issues/events{/number}","events_url":"https://api.github.com/repos/eight04/ansi-viewer/events","assignees_url":"https://api.github.com/repos/eight04/ansi-viewer/assignees{/user}","branches_url":"https://api.github.com/repos/eight04/ansi-viewer/branches{/branch}","tags_url":"https://api.github.com/repos/eight04/ansi-viewer/tags","blobs_url":"https://api.github.com/repos/eight04/ansi-viewer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eight04/ansi-viewer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eight04/ansi-viewer/git/refs{/sha}","trees_url":"https://api.github.com/repos/eight04/ansi-viewer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eight04/ansi-viewer/statuses/{sha}","languages_url":"https://api.github.com/repos/eight04/ansi-viewer/languages","stargazers_url":"https://api.github.com/repos/eight04/ansi-viewer/stargazers","contributors_url":"https://api.github.com/repos/eight04/ansi-viewer/contributors","subscribers_url":"https://api.github.com/repos/eight04/ansi-viewer/subscribers","subscription_url":"https://api.github.com/repos/eight04/ansi-viewer/subscription","commits_url":"https://api.github.com/repos/eight04/ansi-viewer/commits{/sha}","git_commits_url":"https://api.github.com/repos/eight04/ansi-viewer/git/commits{/sha}","comments_url":"https://api.github.com/repos/eight04/ansi-viewer/comments{/number}","issue_comment_url":"https://api.github.com/repos/eight04/ansi-viewer/issues/comments{/number}","contents_url":"https://api.github.com/repos/eight04/ansi-viewer/contents/{+path}","compare_url":"https://api.github.com/repos/eight04/ansi-viewer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eight04/ansi-viewer/merges","archive_url":"https://api.github.com/repos/eight04/ansi-viewer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eight04/ansi-viewer/downloads","issues_url":"https://api.github.com/repos/eight04/ansi-viewer/issues{/number}","pulls_url":"https://api.github.com/repos/eight04/ansi-viewer/pulls{/number}","milestones_url":"https://api.github.com/repos/eight04/ansi-viewer/milestones{/number}","notifications_url":"https://api.github.com/repos/eight04/ansi-viewer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eight04/ansi-viewer/labels{/name}","releases_url":"https://api.github.com/repos/eight04/ansi-viewer/releases{/id}","deployments_url":"https://api.github.com/repos/eight04/ansi-viewer/deployments","created_at":"2016-04-25T08:38:32Z","updated_at":"2018-05-15T14:51:07Z","pushed_at":"2018-06-20T20:13:25Z","git_url":"git://github.com/eight04/ansi-viewer.git","ssh_url":"git@github.com:eight04/ansi-viewer.git","clone_url":"https://github.com/eight04/ansi-viewer.git","svn_url":"https://github.com/eight04/ansi-viewer","homepage":null,"size":525,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":3,"watchers":4,"default_branch":"master"}},"base":{"label":"eight04:master","ref":"master","sha":"b441c9f9d30dc42f370ddb16df0fbd66cdb29ef2","user":{"login":"eight04","id":1324510,"node_id":"MDQ6VXNlcjEzMjQ1MTA=","avatar_url":"https://avatars2.githubusercontent.com/u/1324510?v=4","gravatar_id":"","url":"https://api.github.com/users/eight04","html_url":"https://github.com/eight04","followers_url":"https://api.github.com/users/eight04/followers","following_url":"https://api.github.com/users/eight04/following{/other_user}","gists_url":"https://api.github.com/users/eight04/gists{/gist_id}","starred_url":"https://api.github.com/users/eight04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eight04/subscriptions","organizations_url":"https://api.github.com/users/eight04/orgs","repos_url":"https://api.github.com/users/eight04/repos","events_url":"https://api.github.com/users/eight04/events{/privacy}","received_events_url":"https://api.github.com/users/eight04/received_events","type":"User","site_admin":false},"repo":{"id":57025522,"node_id":"MDEwOlJlcG9zaXRvcnk1NzAyNTUyMg==","name":"ansi-viewer","full_name":"eight04/ansi-viewer","owner":{"login":"eight04","id":1324510,"node_id":"MDQ6VXNlcjEzMjQ1MTA=","avatar_url":"https://avatars2.githubusercontent.com/u/1324510?v=4","gravatar_id":"","url":"https://api.github.com/users/eight04","html_url":"https://github.com/eight04","followers_url":"https://api.github.com/users/eight04/followers","following_url":"https://api.github.com/users/eight04/following{/other_user}","gists_url":"https://api.github.com/users/eight04/gists{/gist_id}","starred_url":"https://api.github.com/users/eight04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eight04/subscriptions","organizations_url":"https://api.github.com/users/eight04/orgs","repos_url":"https://api.github.com/users/eight04/repos","events_url":"https://api.github.com/users/eight04/events{/privacy}","received_events_url":"https://api.github.com/users/eight04/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/eight04/ansi-viewer","description":"A Firefox addon which let you view .ans file in the browser.","fork":false,"url":"https://api.github.com/repos/eight04/ansi-viewer","forks_url":"https://api.github.com/repos/eight04/ansi-viewer/forks","keys_url":"https://api.github.com/repos/eight04/ansi-viewer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/eight04/ansi-viewer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/eight04/ansi-viewer/teams","hooks_url":"https://api.github.com/repos/eight04/ansi-viewer/hooks","issue_events_url":"https://api.github.com/repos/eight04/ansi-viewer/issues/events{/number}","events_url":"https://api.github.com/repos/eight04/ansi-viewer/events","assignees_url":"https://api.github.com/repos/eight04/ansi-viewer/assignees{/user}","branches_url":"https://api.github.com/repos/eight04/ansi-viewer/branches{/branch}","tags_url":"https://api.github.com/repos/eight04/ansi-viewer/tags","blobs_url":"https://api.github.com/repos/eight04/ansi-viewer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/eight04/ansi-viewer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/eight04/ansi-viewer/git/refs{/sha}","trees_url":"https://api.github.com/repos/eight04/ansi-viewer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/eight04/ansi-viewer/statuses/{sha}","languages_url":"https://api.github.com/repos/eight04/ansi-viewer/languages","stargazers_url":"https://api.github.com/repos/eight04/ansi-viewer/stargazers","contributors_url":"https://api.github.com/repos/eight04/ansi-viewer/contributors","subscribers_url":"https://api.github.com/repos/eight04/ansi-viewer/subscribers","subscription_url":"https://api.github.com/repos/eight04/ansi-viewer/subscription","commits_url":"https://api.github.com/repos/eight04/ansi-viewer/commits{/sha}","git_commits_url":"https://api.github.com/repos/eight04/ansi-viewer/git/commits{/sha}","comments_url":"https://api.github.com/repos/eight04/ansi-viewer/comments{/number}","issue_comment_url":"https://api.github.com/repos/eight04/ansi-viewer/issues/comments{/number}","contents_url":"https://api.github.com/repos/eight04/ansi-viewer/contents/{+path}","compare_url":"https://api.github.com/repos/eight04/ansi-viewer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/eight04/ansi-viewer/merges","archive_url":"https://api.github.com/repos/eight04/ansi-viewer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/eight04/ansi-viewer/downloads","issues_url":"https://api.github.com/repos/eight04/ansi-viewer/issues{/number}","pulls_url":"https://api.github.com/repos/eight04/ansi-viewer/pulls{/number}","milestones_url":"https://api.github.com/repos/eight04/ansi-viewer/milestones{/number}","notifications_url":"https://api.github.com/repos/eight04/ansi-viewer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/eight04/ansi-viewer/labels{/name}","releases_url":"https://api.github.com/repos/eight04/ansi-viewer/releases{/id}","deployments_url":"https://api.github.com/repos/eight04/ansi-viewer/deployments","created_at":"2016-04-25T08:38:32Z","updated_at":"2018-05-15T14:51:07Z","pushed_at":"2018-06-20T20:13:25Z","git_url":"git://github.com/eight04/ansi-viewer.git","ssh_url":"git@github.com:eight04/ansi-viewer.git","clone_url":"https://github.com/eight04/ansi-viewer.git","svn_url":"https://github.com/eight04/ansi-viewer","homepage":null,"size":525,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":3,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/eight04/ansi-viewer/pulls/10"},"html":{"href":"https://github.com/eight04/ansi-viewer/pull/10"},"issue":{"href":"https://api.github.com/repos/eight04/ansi-viewer/issues/10"},"comments":{"href":"https://api.github.com/repos/eight04/ansi-viewer/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/eight04/ansi-viewer/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/eight04/ansi-viewer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/eight04/ansi-viewer/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/eight04/ansi-viewer/statuses/2c292ba43ac4f2c35b8aa3e4a5db2a7ca69f18ad"}},"author_association":"OWNER"}}
{"actor":{"display_login":"eight04"}}