Skip to content

Commit

Permalink
maybe finish the first build
Browse files Browse the repository at this point in the history
  • Loading branch information
madneal committed May 27, 2017
1 parent a22fce4 commit db55a84
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion scripts/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@ chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.query({active: true, currentWindow: true}, function(arrayOfTabs) {
const activeTab = arraryOfTabs[0];
const url = activeTab.url + '?format=json';

fetch(url)
.then(function(res) {
if (res.ok) {
return res.text();
} else {
console.error('The fetch fails, and the response code is ' + res.status);
}
})
.then(function(text) {
const story = parseJsonToMarkdown(text);
console.log(story);
})
.catch(function(err) {
console.error(err);
})
})
})

Expand Down Expand Up @@ -47,6 +61,7 @@ function parseJsonToMarkdown(jsonStr) {
story.markdown.push(text);
}
}
return story;
}

function processSection(s) {
Expand Down

0 comments on commit db55a84

Please sign in to comment.