Skip to content

Commit 824414a

Browse files
committed
resolve conflicts
2 parents f19ad8a + 1bc3d7d commit 824414a

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

manifest.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
"permissions": [
1414
"http://github.com/*",
1515
"https://github.com/*",
16-
"storage"
16+
"https://api.github.com/*",
17+
"storage",
18+
"activeTab"
1719
],
1820
"background" : {
1921
"scripts" : [ "src/background.js" ]

src/background.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,27 @@
33
const GITHUB_TOKEN_KEY = 'x-github-token'
44
const TOKEN_FEATURE_INFORMATION_KEY = 'user-knows-token-feature'
55

6-
const setGithubToken = (key, cb) => {
6+
const storage = chrome.storage.sync || chrome.storage.local
7+
8+
function setGithubToken (key, cb) {
79
const obj = {}
810

911
obj[GITHUB_TOKEN_KEY] = key
1012

11-
chrome.storage.sync.set(obj, () => {
13+
storage.set(obj, function () {
1214
alert('Your Github token has been set successfully. Reload the Github page to see changes.')
1315

1416
cb()
1517
})
1618
}
1719

18-
const handleOldGithubToken = (cb) => {
19-
chrome.storage.sync.get(GITHUB_TOKEN_KEY, (storedData) => {
20+
function handleOldGithubToken (cb) {
21+
storage.get(GITHUB_TOKEN_KEY, function (storedData) {
2022
const oldGithubToken = storedData[GITHUB_TOKEN_KEY]
2123

2224
if (oldGithubToken) {
2325
if (confirm('You have already set your Github token. Do you want to remove it?')) {
24-
chrome.storage.sync.remove(GITHUB_TOKEN_KEY, () => {
26+
storage.remove(GITHUB_TOKEN_KEY, function () {
2527
alert('You have successfully removed Github token. Click extension icon again to set a new token.')
2628

2729
cb(false)
@@ -39,11 +41,11 @@ const userNowKnowsAboutGithubTokenFeature = (cb) => {
3941
const obj = {}
4042
obj[TOKEN_FEATURE_INFORMATION_KEY] = true
4143

42-
chrome.storage.sync.set(obj, cb)
44+
storage.set(obj, cb)
4345
}
4446

45-
const informUserAboutGithubTokenFeature = () => {
46-
chrome.storage.sync.get(TOKEN_FEATURE_INFORMATION_KEY, (storedData) => {
47+
function informUserAboutGithubTokenFeature () {
48+
storage.get(TOKEN_FEATURE_INFORMATION_KEY, function (storedData) {
4749
const userKnows = storedData[TOKEN_FEATURE_INFORMATION_KEY]
4850

4951
if (!userKnows) {

src/inject.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const API = 'https://api.github.com/repos/'
44
const LI_TAG_ID = 'github-repo-size'
55
const GITHUB_TOKEN_KEY = 'x-github-token'
66

7+
const storage = chrome.storage.sync || chrome.storage.local
8+
79
let githubToken
810

911
const isTree = (uri) => {
@@ -153,7 +155,7 @@ const checkForRepoPage = () => {
153155
}
154156
}
155157

156-
chrome.storage.sync.get(GITHUB_TOKEN_KEY, (data) => {
158+
storage.get(GITHUB_TOKEN_KEY, function (data) {
157159
githubToken = data[GITHUB_TOKEN_KEY]
158160

159161
chrome.storage.onChanged.addListener((changes, namespace) => {

0 commit comments

Comments
 (0)