{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/pulls/comments/187387497","pull_request_review_id":119154255,"id":187387497,"diff_hunk":"@@ -6,14 +6,136 @@\n \n /* globals browser */\n \n-const gURLThankYou = \"https://mozilla.github.io/webcompat-blipz-experiment/thanks.html\";\n+let gCurrentlyPromptingTabId;\n+\n+const Config = (function() {\n+  class Config {\n+    constructor() {\n+      this._neverShowAgain = false;\n+      this._skipPrivateBrowsingTabs = true;\n+      this._lastPromptTime = 0;\n+      this._domainsToCheck = {\n+        \"accounts.google.com\": 0,\n+        \"amazon.com\": 0,\n+        \"amazon.in\": 0,\n+        \"bing.com\": 0,\n+        \"docs.google.com\": 0,\n+        \"drive.google.com\": 0,\n+        \"facebook.com\": 0,\n+        \"flipkart.com\": 0,\n+        \"github.com\": 0,\n+        \"google.co.in\": 0,\n+        \"google.com\": 0,\n+        \"inbox.google.com\": 0,\n+        \"instagram.com\": 0,\n+        \"linkedin.com\": 0,\n+        \"mail.google.com\": 0,\n+        \"netflix.com\": 0,\n+        \"pandora.com\": 0,\n+        \"play.google.com\": 0,\n+        \"reddit.com\": 0,\n+        \"soundcloud.com\": 0,\n+        \"theverge.com\": 0,\n+        \"twitch.tv\": 0,\n+        \"twitter.com\": 0,\n+        \"web.whatsapp.com\": 0,\n+        \"youtube.com\": 0,\n+      };\n+    }\n \n-const gMinimumFrequencyBeforeRePrompting = 1000 * 20; // 20 seconds (for testing)\n-const gSkipPrivateBrowsingTabs = true;\n+    load() {\n+      // TBD\n+      return Promise.resolve();\n+    }\n \n-const gDomainCheckTimestamps = {};\n+    save(options) {\n+      // TBD\n+      console.info(\"Saving options\", options);\n+    }\n \n-let gNeverShowAgain = false;\n+    onUserPrompted(domain) {\n+      const now = Date.now();\n+      this._lastPromptTime = now;\n+      this._domainsToCheck[domain] = now;\n+      this.save({\n+        lastPromptTime: now,\n+        domainsToMatch: this._domainsToCheck\n+      });\n+    }\n+\n+    findDomainMatch(domain) {\n+      for (const candidate of Object.keys(this._domainsToCheck)) {\n+        if (domain.endsWith(candidate)) {\n+          return candidate;\n+        }\n+      }\n+      return undefined;\n+    }\n+\n+    shouldPromptUserNow(domain) {\n+      // Prompt at most once a day, at a minimum once every three days,\n+      // for a maximum of five prompts per user and one prompt per domain.\n+      if (this._lastPromptTime) {\n+        const now = Date.now();\n+        const oneDay = 1000 * 60 * 60 * 24;\n+        const nextValidCheckTime = this._lastPromptTime + oneDay;\n+        const nextNecessaryCheckTime = this._lastPromptTime - (oneDay * 3);\n+        if (now < nextValidCheckTime &&\n+            (now > nextNecessaryCheckTime || Math.random() > 0.5)) {","path":"webextension/background.js","position":84,"original_position":84,"commit_id":"874ab4a39c9e8184bc62bb0a58be460a8c76162d","original_commit_id":"874ab4a39c9e8184bc62bb0a58be460a8c76162d","user":{"login":"miketaylr","id":67283,"avatar_url":"https://avatars1.githubusercontent.com/u/67283?v=4","gravatar_id":"","url":"https://api.github.com/users/miketaylr","html_url":"https://github.com/miketaylr","followers_url":"https://api.github.com/users/miketaylr/followers","following_url":"https://api.github.com/users/miketaylr/following{/other_user}","gists_url":"https://api.github.com/users/miketaylr/gists{/gist_id}","starred_url":"https://api.github.com/users/miketaylr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miketaylr/subscriptions","organizations_url":"https://api.github.com/users/miketaylr/orgs","repos_url":"https://api.github.com/users/miketaylr/repos","events_url":"https://api.github.com/users/miketaylr/events{/privacy}","received_events_url":"https://api.github.com/users/miketaylr/received_events","type":"User","site_admin":false},"body":"So we're saying, if it's too early to prompt, OR if it's OK to prompt and you roll the correct dice, we prompt you. I think that sounds good.","created_at":"2018-05-10T16:41:47Z","updated_at":"2018-05-10T16:45:47Z","html_url":"https://github.com/mozilla/webcompat-blipz-experiment/pull/39#discussion_r187387497","pull_request_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/pulls/39","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/pulls/comments/187387497"},"html":{"href":"https://github.com/mozilla/webcompat-blipz-experiment/pull/39#discussion_r187387497"},"pull_request":{"href":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/pulls/39"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/pulls/39","id":187236676,"html_url":"https://github.com/mozilla/webcompat-blipz-experiment/pull/39","diff_url":"https://github.com/mozilla/webcompat-blipz-experiment/pull/39.diff","patch_url":"https://github.com/mozilla/webcompat-blipz-experiment/pull/39.patch","issue_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/issues/39","number":39,"state":"open","locked":false,"title":"Implement prompting logic #25","user":{"login":"wisniewskit","id":419743,"avatar_url":"https://avatars1.githubusercontent.com/u/419743?v=4","gravatar_id":"","url":"https://api.github.com/users/wisniewskit","html_url":"https://github.com/wisniewskit","followers_url":"https://api.github.com/users/wisniewskit/followers","following_url":"https://api.github.com/users/wisniewskit/following{/other_user}","gists_url":"https://api.github.com/users/wisniewskit/gists{/gist_id}","starred_url":"https://api.github.com/users/wisniewskit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wisniewskit/subscriptions","organizations_url":"https://api.github.com/users/wisniewskit/orgs","repos_url":"https://api.github.com/users/wisniewskit/repos","events_url":"https://api.github.com/users/wisniewskit/events{/privacy}","received_events_url":"https://api.github.com/users/wisniewskit/received_events","type":"User","site_admin":false},"body":"Note that I've made a Config object which will make it easier to load/save configuration to about:config, but have deferred the actual implementation of about:config stuff to a future issue.","created_at":"2018-05-10T16:10:47Z","updated_at":"2018-05-10T16:45:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"67657193fb879ab63f53cd4c70d63b6aad9c9bd4","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/pulls/39/commits","review_comments_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/pulls/39/comments","review_comment_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/issues/39/comments","statuses_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/statuses/874ab4a39c9e8184bc62bb0a58be460a8c76162d","head":{"label":"mozilla:issues/25","ref":"issues/25","sha":"874ab4a39c9e8184bc62bb0a58be460a8c76162d","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars2.githubusercontent.com/u/131524?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":131010123,"name":"webcompat-blipz-experiment","full_name":"mozilla/webcompat-blipz-experiment","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars2.githubusercontent.com/u/131524?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/webcompat-blipz-experiment","description":null,"fork":false,"url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment","forks_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/forks","keys_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/teams","hooks_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/hooks","issue_events_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/events","assignees_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/tags","blobs_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/languages","stargazers_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/stargazers","contributors_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/contributors","subscribers_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/subscribers","subscription_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/subscription","commits_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/merges","archive_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/downloads","issues_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/deployments","created_at":"2018-04-25T13:24:59Z","updated_at":"2018-05-09T19:56:50Z","pushed_at":"2018-05-10T16:10:47Z","git_url":"git://github.com/mozilla/webcompat-blipz-experiment.git","ssh_url":"git@github.com:mozilla/webcompat-blipz-experiment.git","clone_url":"https://github.com/mozilla/webcompat-blipz-experiment.git","svn_url":"https://github.com/mozilla/webcompat-blipz-experiment","homepage":null,"size":70,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":13,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":1,"open_issues":13,"watchers":0,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"0471c0ae26cdc8ffe2e42599fec70f67cd990264","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars2.githubusercontent.com/u/131524?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":131010123,"name":"webcompat-blipz-experiment","full_name":"mozilla/webcompat-blipz-experiment","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars2.githubusercontent.com/u/131524?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/webcompat-blipz-experiment","description":null,"fork":false,"url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment","forks_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/forks","keys_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/teams","hooks_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/hooks","issue_events_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/events","assignees_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/tags","blobs_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/languages","stargazers_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/stargazers","contributors_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/contributors","subscribers_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/subscribers","subscription_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/subscription","commits_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/merges","archive_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/downloads","issues_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/deployments","created_at":"2018-04-25T13:24:59Z","updated_at":"2018-05-09T19:56:50Z","pushed_at":"2018-05-10T16:10:47Z","git_url":"git://github.com/mozilla/webcompat-blipz-experiment.git","ssh_url":"git@github.com:mozilla/webcompat-blipz-experiment.git","clone_url":"https://github.com/mozilla/webcompat-blipz-experiment.git","svn_url":"https://github.com/mozilla/webcompat-blipz-experiment","homepage":null,"size":70,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":13,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":1,"open_issues":13,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/pulls/39"},"html":{"href":"https://github.com/mozilla/webcompat-blipz-experiment/pull/39"},"issue":{"href":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/issues/39"},"comments":{"href":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/issues/39/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/pulls/39/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/pulls/39/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/webcompat-blipz-experiment/statuses/874ab4a39c9e8184bc62bb0a58be460a8c76162d"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"miketaylr"}}